home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / 123w20.zip / 123WRITE.DOC < prev    next >
Text File  |  1990-11-15  |  162KB  |  4,456 lines

  1.  
  2.  
  3.  
  4.         OVERVIEW                                          1
  5.         FILES INCLUDED WITH 123W20.ZIP                    2
  6.         LICENSE                                           2
  7.         DISTRIBUTION                                      3
  8.         REGISTRATION                                      3
  9.         SUPPORT                                           3
  10.         REQUIREMENTS                                      5
  11.         GENERATING THE 123-WRITE LIBRARIES                5
  12.         MAKENEAR.BAT                                      6
  13.         MAKEFAR.BAT                                       7
  14.         COMPILING                                         8
  15.         CALLING SEQUENCE                                  9
  16.         DEFAULT SETTINGS-lFileOpen                       12
  17.         DEFAULT SETTINGS-lFileAppend                     13
  18.         SOME GUIDELINES                                  14
  19.         FINDING YOUR WAY AROUND THE SPREADSHEET          15
  20.         WHAT'S NEW?                                      15
  21.         lBoolean                                         18
  22.         lCellFunction                                    19
  23.         lCellMath                                        23
  24.         lClose                                           24
  25.         lCol                                             25
  26.         lColFunction                                     26
  27.         lConstMath                                       27
  28.         lDate                                            28
  29.         lDown                                            29
  30.         lFileAppend                                      30
  31.         lFileOpen                                        32
  32.         lGetLoc                                          33
  33.         lGlobal                                          34
  34.         lHideCol                                         35
  35.         lLeft                                            36
  36.         lLineFeed                                        37
  37.         lLink                                            38
  38.         lMultiCellMath                                   40
  39.         lPrintBorders                                    43
  40.         lPrintMargins                                    44
  41.         lPrintRange                                      45
  42.         lPrintSetup                                      46
  43.         lPrintTitle                                      47
  44.         lRange                                           48
  45.         lRight                                           49
  46.         lRowFunction                                     50
  47.         lSetCellForm                                     51
  48.         lSetCol                                          53
  49.         lSetCols                                         54
  50.         lSetDateForm                                     55
  51.         lSetLoc                                          56
  52.         lSetStrForm                                      57
  53.         lSetTimeForm                                     58
  54.         lSortKey                                         59
  55.         lSortRange                                       60
  56.         lTime                                            61
  57.         lTimeNow                                         62
  58.         lToday                                           63
  59.  
  60.  
  61.                                         i
  62.  
  63.  
  64.  
  65.         lUp                                              64
  66.         lWriteErr                                        65
  67.         lWriteInt                                        66
  68.         lWriteNum                                        66
  69.         lWriteStr                                        67
  70.         ERRORS                                           68
  71.         CONTACTING the author                            69
  72.         APPENDIX A - DOS Error Codes                     70
  73.         Routine Reference                                71
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.                                         ii
  123.  
  124.                                                        123-Write ver 2.0
  125.                                     Copyright (c) 1990, Thomas J. Vought
  126.  
  127.  
  128.         OVERVIEW
  129.  
  130.         123-Write  is a collection of assembly language sub  programs  to
  131.         write  a Lotus 1-2-3 file from within a QB 4+, QBX, BASIC 6.0  or
  132.         BASIC 7.0+ program.  Not all of 1-2-3's functions and  operations
  133.         are  available,  yet I feel that I've included some of  the  most
  134.         frequently needed.
  135.  
  136.         In  the past I've always written programs that allow the user  to
  137.         specify  where  report  output should be  directed,  the  screen,
  138.         printer  a  print image file, etc.  These routines were  an  out-
  139.         growth  of two needs.  The first one was just wanting  to  "dress
  140.         up"  my  code a little more, and add a little  versatility.  What
  141.         could be more polished than writing a report's output directly to
  142.         a 1-2-3 spreadsheet file?
  143.  
  144.         The second, and more important reason, was all the work  involved
  145.         in  1-2-3  to import, transfer and work with  data  from  another
  146.         program.   One commercial package offers a "Lotus  1-2-3"  export
  147.         option  on  their report menu.  When I needed just  that  ability
  148.         once  I was a more then a little disappointed to find the  output
  149.         file  nothing more then a comma delimited sequential  file.   Im-
  150.         porting  to Lotus was simple, but dates became strings,  and  all
  151.         the data had to be shifted around within Lotus to be of any  use.
  152.         Writing  a macro to handle the job was a chore, and it was  quite
  153.         slow doing conversions of ASCII formatted dates etc.
  154.  
  155.         123-Write  will provide you with the ability to take  that  comma
  156.         delimited file and convert it directly into a formatted worksheet
  157.         for  example.  Read and write the data just the way you need  it.
  158.         Generate an up to date spreadsheet from your own BASIC data files
  159.         whenever needed.  You won't have to write out an ASCII sequential
  160.         file,  and  then write Lotus 1-2-3 Macros to read the  data  file
  161.         into your worksheet, and reformat it.
  162.  
  163.         Lotus,  and 1-2-3 are registered trademarks of Lotus  Development
  164.         Corporation, and Microsoft is a registered trademark of Microsoft
  165.         Corporation, by the way.
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.                                         1
  185.  
  186.                                                        123-Write ver 2.0
  187.                                     Copyright (c) 1990, Thomas J. Vought
  188.  
  189.         FILES INCLUDED in the 123W20.ZIP:
  190.  
  191.  
  192.         123W20.LIB         Skeleton .LIB file for all BASIC programs
  193.                            - EXCEPT - BC 7.0+ with far strings.
  194.  
  195.         123W20F.LIB        Skeleton .LIB file for BC 7.0+ programs with
  196.                            - FAR STRINGS ONLY -
  197.  
  198.         LCOLS.BAS          Source code interface for lCols routine.
  199.         LDATE.BAS          Source code interface for lDate routine.
  200.         LTIME.BAS          Source code interface for lTime routine.
  201.  
  202.         MAKENEAR.BAT       Compiles the .BAS files, adds them to
  203.                                123W20.LIB, generates the non-QBX
  204.                                123W20.QLB file for QB 4.0+.
  205.  
  206.         MAKEFAR.BAT        Compiles the .BAS files, adds them to
  207.                                123W20F.LIB, generates the QBX 123W20F.QLB
  208.                                QuickLib file.
  209.  
  210.         123WRITE.DOC       Complete documentation for version 2.0
  211.  
  212.         123WRITE.BI        An ASCII include file that DECLARES all the
  213.                                     123-Write routines.
  214.  
  215.         123DEMO2.BAS       Demonstration of a few of the routines.
  216.                               example: QB 123DEMO2 /L 123W20.QLB
  217.                                    or: QBX 123DEMO2 /L 123W20F.QLB
  218.  
  219.         The  .LIB  files  are "skeletons" because they  contain  all  the
  220.         assembly  language routines, but do not contain the  three  BASIC
  221.         routines.   The MAKENEAR and MAKEFAR batch files handle the  com-
  222.         piling, insertion in the object file library and building of  the
  223.         QuickLibrary for you.
  224.  
  225.  
  226.         LICENSE
  227.  
  228.         123-Write  is not PUBLIC DOMAIN software.  It is  distributed  as
  229.         Shareware,  and as such, non registered users are granted  a  li-
  230.         cense to use 123-Write for a limited evaluation period, for  your
  231.         own  noncommercial use.  Use of the routines in this archive  are
  232.         not  to  be used in any software that you sell, offer  for  sale,
  233.         generate in the course of your employment, or after a  reasonable
  234.         evaluation  period (30 days).  All that requires registering  the
  235.         copy.
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.                                         2
  246.  
  247.                                                        123-Write ver 2.0
  248.                                     Copyright (c) 1990, Thomas J. Vought
  249.  
  250.         DISTRIBUTION
  251.  
  252.              You may copy and freely distribute 123-Write, as long as:
  253.  
  254.              No fee is charged. (Recognized user groups and clubs may
  255.                                    charge a nominal fee for expenses.)
  256.              All the files included within this archive are distributed
  257.                    intact and without any modification(s).
  258.  
  259.         WARRANTY
  260.  
  261.         This software is distributed AS IS without warranty of any  kind,
  262.         express or implied, including but not limited to implied  warran-
  263.         ties for the software's quality, performance, merchantability, or
  264.         fitness for any particular purpose.  Neither myself or any dealer
  265.         or  distributor  shall be liable with respect to  any  liability,
  266.         loss,  or  damage  caused, or alleged to be  caused  directly  or
  267.         indirectly by this software.
  268.  
  269.         REGISTRATION
  270.  
  271.         If you use the 123-Write routines within any application that you
  272.         distribute, or in the course of your employment, registration  at
  273.         $25.00 is mandatory.  If you find 123-Write convenient to use, if
  274.         you find 123-Write a help to your programming, a $25.00 registra-
  275.         tion  is  expected.
  276.  
  277.         With  each  registration you will receive a diskette with  a  li-
  278.         censed (distributable) copy of the library, be listed to  receive
  279.         a diskette of the next release (if any) of 123-Write, and receive
  280.         what you may possibly find an interesting text file on the  Lotus
  281.         worksheet file format. (perhaps you may be interested in  reading
  282.         a worksheet file before I get finished with 123-READ, but  that's
  283.         another story.)
  284.  
  285.         SUPPORT
  286.  
  287.         Questions  will be answered when asked.  Fastest method for  non-
  288.         registered users may be via a call to The Off Hour Rockers BBS in
  289.         Sayreville NJ.  201-727-6917 and 201-727-6785.  Settings are  N81
  290.         9600/2400/1200  baud 24 hours a day.  Join the  BASIC  conference
  291.         (j;7)  after logging on, and address your message to  Tom  Vought
  292.         and  I'll reply as soon as possible.  The BBS is founded on  free
  293.         spirit  principles  and  is a little off the wall  at  times,  no
  294.         hassle about signing on or downloads.  Please be sure to use  you
  295.         real  name though, as "handles" are considered quite tacky.   The
  296.         latest version of 123-Write is always available for download from
  297.         conference 7.
  298.  
  299.         CIS ID:  70054,1367   (Infrequent, so use CIS E-Mail)
  300.         US  Mail to the address on the registration form will  also  work
  301.         reasonably well.
  302.         A registration form for your use follows.
  303.  
  304.  
  305.  
  306.                                         3
  307.  
  308.                                                        123-Write ver 2.0
  309.                                     Copyright (c) 1990, Thomas J. Vought
  310.  
  311.         Please make checks payable and mail To:
  312.  
  313.               Thomas J. Vought
  314.               5 John Street
  315.               Morganville, NJ  07751
  316.  
  317.         Registration of: 123-Write ver 2.0
  318.  
  319.  
  320.                      Name: _____________________________________________
  321.  
  322.  
  323.              Company Name: _____________________________________________
  324.  
  325.         Mailing Address
  326.  
  327.                    Street: _____________________________________________
  328.  
  329.  
  330.         Town, State & Zip: _____________________________________________
  331.  
  332.  
  333.                     Phone: ____________________________________________
  334.  
  335.  
  336.         Do you have a modem? ______________      Disk format  ____ 3.50"
  337.  
  338.                                                               ____ 5.25"
  339.         Where did you receive 123-Write from?  (Just curious.)
  340.  
  341.  
  342.  
  343.         What functions, @formulas, or other esoteric stuff would you like
  344.         to see included in any future releases of 123-Write?
  345.  
  346.  
  347.  
  348.  
  349.  
  350.         Comments?:
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.                                         4
  368.  
  369.                                                        123-Write ver 2.0
  370.                                     Copyright (c) 1990, Thomas J. Vought
  371.  
  372.         OK,  I think I have all that stuff about registration out of  the
  373.         way.   Only  one  more item.  Routines are added  based  on  user
  374.         suggestions, registered or not.
  375.  
  376.         Requirements:
  377.  
  378.         123-Write (2.0) was developed and tested using Microsoft's  Macro
  379.         Assembler  ver 5.1, Microsoft's Basic Compiler versions  6.0  and
  380.         7.1 and both QB ver 4.5 and QBX ver 7.1.
  381.  
  382.         The  worksheet  files  written are compatible  with  all  current
  383.         versions of Lotus 1-2-3.  Specific features of Release 3 are  not
  384.         supported,  though the spreadsheets written can be loaded by  Re-
  385.         lease  3 without problem.  Care should be taken to avoid  calling
  386.         routines  that  are not supported by the  target  Lotus  version.
  387.         I've  tried  to make note of Lotus version  requirements  in  the
  388.         routine  index and in the routine descriptions.  If I  missed  or
  389.         made a blatantly greivious error.... Sorry, let me know and  I'll
  390.         correct it in the next revision of the documentation.
  391.  
  392.         123-Write version 2.0 requires DOS version 2.0+.
  393.  
  394.         GENERATING THE 123-WRITE LIBRARIES
  395.  
  396.         Creating  a  quick library and a linker library is  performed  by
  397.         either the MAKENEAR.BAT or MAKEFAR.BAT  files (or both)  included
  398.         with the zip file.
  399.  
  400.         MAKENEAR (page 6) is for:
  401.              QB 4.0,  QB 4.5  and  BC 6.0
  402.  
  403.         MAKEFAR (page 7) is for:
  404.              BC 7.0    near and far string support.
  405.              BC 7.1    near and far string support.
  406.              QBX 7.0   QuickLibrary
  407.              QBX 7.1   QuickLibrary
  408.  
  409.         The preferred method is to work in a sub-directory that has  only
  410.         the 123-Write files in it.
  411.  
  412.         For either batch file, make the 123-Write directory the default.
  413.         Access to:
  414.              LIB.EXE
  415.              LINK.EXE
  416.              and your basic compiler (BC.EXE)
  417.  
  418.         should be assured via your PATH statement.
  419.  
  420.         The   LINKer  will  need  your  quick  library  support   module,
  421.         BQLBxx.LIB or QBXQLB.LIB either in the same directory, or pointed
  422.         to by the LIB= environment variable.
  423.  
  424.  
  425.  
  426.  
  427.  
  428.                                         5
  429.  
  430.                                                        123-Write ver 2.0
  431.                                     Copyright (c) 1990, Thomas J. Vought
  432.  
  433.         If your development environment is QB 4.0, QB 4.5 or BC 6.0:
  434.  
  435.         1.   Ignore the MAKEFAR.BAT batch file entirely.
  436.  
  437.         2.   The syntax for MAKENEAR is:
  438.  
  439.              MAKENEAR compilerName qlbSupportLib [compiler / options]
  440.  
  441.         This  will  create  both the QB  Quick  Library,  123W20.QLB  and
  442.         123W20.LIB.
  443.  
  444.         The compilerName variable is usually BC, unless you keep  various
  445.         versions  of the compiler on your disk, as I do.  Either way  you
  446.         must enter a compiler name.
  447.  
  448.         The  qlbSupportLib variable is the BQLBxx.LIB file that was  sup-
  449.         plied with whatever version of the compiler you are using.  There
  450.         are  a few out there for QB 4.0, so double check.  QB  4.5  users
  451.         should  specify BQLB45.LIB.  If I remember correctly, BC 6.0  was
  452.         supplied with BQLB41.LIB.
  453.  
  454.         Enter  any  compiler switches you usually use in  one  string  if
  455.         needed.   Use /FPI/O instead of /FPI <space> /O.  If you want  to
  456.         generate  multiple libraries for different compiler  switch  set-
  457.         tings,  feel free to run the batch file multiple times,  renaming
  458.         the  resulting  .LIB and .QLB file each time.  If  123W20.LIB  or
  459.         123W20.QLB is found in the current directory when the batch  file
  460.         is  started,  a reminder is printed to move/delete them  and  the
  461.         batch file terminates.
  462.  
  463.         The batch file will compile the BASIC source code files then  add
  464.         them to the 123W20.LIB with LIB.EXE.  After 123W20.LIB is updated
  465.         with the three BASIC object files, LINK is invoked to create  the
  466.         123W20.QLB QuickLibrary.
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.                                         6
  490.  
  491.                                                        123-Write ver 2.0
  492.                                     Copyright (c) 1990, Thomas J. Vought
  493.  
  494.         BASIC 7.0+ users should run the MAKEFAR batch file only.  It will
  495.         generate two .LIB files (123W20.LIB and 123W20F.LIB) and one .QLB
  496.         file, 123W20F.QLB.  The syntax is:
  497.  
  498.              MAKEFAR compilerName [compiler / options]
  499.  
  500.  
  501.         The compilerName variable is usually BC, unless you keep  various
  502.         versions of the compiler on your disk, as I do.
  503.  
  504.         The  MAKEFAR batch file will use the /FS and /FPI switches  auto-
  505.         matically  for 123W20F.LIB and the 123W20F.QLB files.  Any  other
  506.         switches can be added except for /FS, but use care when  choosing
  507.         the switches. The switches need to be entered without any  spaces
  508.         separating them, use /O/T instead of /O <space> /T.
  509.  
  510.         The batch file will compile the BASIC source code files for  near
  511.         string  use  with any switches you supply, then add them  to  the
  512.         123W20.LIB with LIB.EXE.
  513.  
  514.         After  123W20.LIB  is updated with the three  BASIC  near  string
  515.         object  files,  the compiler is invoked again  with  the  /FS/FPI
  516.         switches, plus any you supply, to update the 123W20F.LIB with the
  517.         three BASIC source code files.  Lastly, LINK is invoked to create
  518.         the 123W20F.QLB from 123W20F.LIB.
  519.  
  520.         If you do not supply any switches for the compiler when  invoking
  521.         the batch file, you will have:
  522.  
  523.         123W20.LIB     Default BASIC options of: /FPI and near strings.
  524.                        [You should be able to link with /O code also.]
  525.  
  526.         123W20F.LIB    Far string, /FPI.
  527.  
  528.         123W20F.QLB    Far string, /FPI.
  529.  
  530.         One  note  concerning arrays in EMS memory, the /EA  option  with
  531.         QBX.  I am not sure how the 123-Write routines that access arrays
  532.         directly in memory will behave.  My belief is that when you  pass
  533.         the segment and offset of the selected array element to a library
  534.         routine, the array should be moved by QBX into addressable  memo-
  535.         ry, the EMS page frame, if it's out in never-never land somewhere
  536.         before  the  CALL is invoked.  Then the segment  portion  of  the
  537.         array  would  be  somewhere above A000hex,  and  a  16K  boundary
  538.         shouldn't be crossed.  There doesn't seem to be any firm documen-
  539.         tation on this, so if your machine goes into orbit when a call to
  540.         one  of the array based routines is called, I'd suggest  dropping
  541.         the /EA switch, or making the array $STATIC.  The arrays used are
  542.         small enough that this shouldn't be a hardship.
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.                                         7
  551.  
  552.                                                        123-Write ver 2.0
  553.                                     Copyright (c) 1990, Thomas J. Vought
  554.  
  555.         Notes for both MAKENEAR and MAKEFAR:
  556.  
  557.         If 123W20.LIB or 123W20.QLB already exist in the current directo-
  558.         ry, the batch file will stop and prompt you to remove them.   The
  559.         reason for this is to allow you to tailor, if needed, the library
  560.         files to your working environment.
  561.  
  562.         Take  a  look at the MAKE????.BAT files and feel free  to  modify
  563.         them if needed to your particular needs.  Just don't pass on  the
  564.         123-Write  package with the batch files or the .LIB  files  modi-
  565.         fied, please!
  566.  
  567.         LIB will issue a warning message that the BASIC object files  are
  568.         not  in  the library the first time you  run  MAKENEAR.BAT.   The
  569.         batch file specifies that the BASIC object files be 'replaced' in
  570.         the library file, in case it is run more than once.  The  warning
  571.         message  can  be ignored.  If you rerun the batch file  for  some
  572.         reason  (Different  compiler switches maybe.) the  error  message
  573.         won't appear, and all will be as it should be.
  574.  
  575.  
  576.         A note on BASIC PDS 7.0.
  577.  
  578.         If you haven't upgraded to 7.1 yet, please do so.  No I don't own
  579.         stock  in Microsoft, and I do feel $50.00 for what I  consider  a
  580.         bug fix to be outrageous, but 7.1 seems to be a much more  stable
  581.         product.   Also, if you don't need the far string  memory  space,
  582.         near string routines will run faster.
  583.  
  584.  
  585.         COMPILING with 123WRITE:
  586.  
  587.         When compiling to an .EXE file, it's best to compile from the DOS
  588.         command line,  NOT from within the QuickBASIC environment.  There
  589.         is a switch that QB throws into the LINK command line that  seems
  590.         to cause errors and trashed EXE's.  QBX may also mix near and far
  591.         string .LIB files if you're not careful.
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.                                         8
  612.  
  613.                                                        123-Write ver 2.0
  614.                                     Copyright (c) 1990, Thomas J. Vought
  615.  
  616.         Sequence of 123-Write calls:
  617.  
  618.         There can only be one worksheet file open for writing at a  time.
  619.         The routines need to be called in the proper sequence:
  620.  
  621.         1.   Open the file, of course.
  622.                   Use either:
  623.                        lFileOpen(filename$, errCode%)
  624.                             Supply a fully qualified file name with
  625.                             the drive and path if desired.  An existing
  626.                             file will be over-written.
  627.                   Or
  628.                        lFileAppend(filename$, errCode%)
  629.                              To open an existing worksheet file to add
  630.                              on to it.
  631.  
  632.         2.   Write any column width settings desired.
  633.                   Use either:
  634.                        lSetCol(column%,colWidth%)
  635.                             for a single column width setting.
  636.                   Or
  637.                        lSetCols(columnWidths%())
  638.                             for a variety of columns.
  639.  
  640.         3.   Set the cell format for strings and numeric data if other
  641.               then the defaults of left-aligned label cells and "default"
  642.               numeric cells.  See page 12 for default set ups.
  643.  
  644.         4.   Set the starting column and row, if other than:
  645.                   0,0 (A1) if lFileOpen was used or the
  646.                   {end}{home} cell if lFileAppend was used.
  647.  
  648.         5.   Write the data.
  649.  
  650.         6.   Close the file.
  651.                   CALL lClose
  652.  
  653.         Closing  the  file  is a must.  If it's not done via  a  call  to
  654.         lClose, you'll get a "Part of File Missing" error from Lotus when
  655.         loading the spreadsheet.  Lotus needs certain information when it
  656.         loads  a worksheet, and the information can't be written  to  the
  657.         file by 123-Write unless you call the lClose sub-program to close
  658.         the file.  If a worksheet file is not closed, the disk  directory
  659.         will not be updated, and a file handle will lost from DOS.
  660.  
  661.         The  worksheet file is opened and manipulated by using  DOS  file
  662.         access calls, not BASIC file calls.  One important item to remem-
  663.         ber is:  If you use  a CLOSE (all) statement in your program, the
  664.         worksheet file WILL NOT be closed.  This is just the opposite  of
  665.         the behavior in earlier versions of 123-Write.
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.                                         9
  673.  
  674.                                                        123-Write ver 2.0
  675.                                     Copyright (c) 1990, Thomas J. Vought
  676.  
  677.         When  the  spreadsheet file is opened, either with  lFileOpen  or
  678.         lFileAppend, the lClose routine is logged with BASIC.  What  this
  679.         means  is that if you're working in the  QuickBASIC  environment,
  680.         and  your  program terminates abnormally, lClose will  be  called
  681.         automatically.  If you make a change to your program while  step-
  682.         ping  through  it, and QuickBASIC prompts that  "You'll  have  to
  683.         restart  your  program", and you elect to  restart  the  program,
  684.         lClose will be called before control is passed back to you.  What
  685.         that  means is that you should not try to write to a  spreadsheet
  686.         file that was opened before you made the change, by assuming it's
  687.         still open and stepping 'around' a call to lFileOpen.  Check your
  688.         BASIC  manual for a description of the B_OnExit routine,  in  the
  689.         mixed  language  programming guide, for a better  description  of
  690.         what this all means.
  691.  
  692.         Another item of note is range names.  If your spreadsheet may  be
  693.         read by a word processor, or manipulated by some other commerical
  694.         product, then keep the following in mind.
  695.  
  696.         When Lotus saves a spreadsheet to disk, it writes the spreadsheet
  697.         in  a consistent manner.  A certain amount of data is written  at
  698.         the  start of the file, before the cell contents.  As  the  cells
  699.         are  written, they are placed in the file in a row by  row,  left
  700.         column  to right column sequence (A1, B1, C1, A2, B2, C2, A3,  B3
  701.         etc).  123-Write writes as much info as needed at the start  when
  702.         lFileOpen  is  called,  then as calls are made  from  BASIC,  the
  703.         specified data is appended to the file.  With 123-Write, you  can
  704.         write almost anything anywhere you'd like in the file.  Matter of
  705.         fact  I  think that's a nice feature, and Lotus  and  some  clone
  706.         spreadsheet programs don't seem to have a problem with  'anything
  707.         goes'  style of files, a setting change or a repeated  cell  just
  708.         replaces  the previously read data.  The problem arises when  you
  709.         you  use a 'viewer' or try to import to a word processor.
  710.  
  711.         I use Wordstar, so I'll use that product as an example.  When the
  712.         'other'  product reads the file, it may assume that the file  was
  713.         written  by  Lotus et al.  If it doesn't find range  names  where
  714.         Lotus  would have placed them, it might assume that the file  has
  715.         no  range  names.   Wordstar  5.0 behaves  this  way.   When  the
  716.         123DEMO2.BAS  file was written, calls to lRangeName  were  inter-
  717.         spersed  throughout  hte  program.  As each  'page'  routine  was
  718.         called, the range would be defined with lRangeName at the end  of
  719.         the SUB.  When Lotus read the file in, no problem.  However, when
  720.         I  asked  Wordstar to import the file, the only  option  WordStar
  721.         would give me was to import the whole file.  No range names  were
  722.         presented.   Changing the sequence of calls in the  demo  program
  723.         corrected the problem.  What I did was to write the  "WriteRange-
  724.         Names" sub program and moved all the calls into it.  Then insert-
  725.         ed a call to the new routine immediately after the call to lFile-
  726.         Open,  before any cells were written to the file.   Wordstar  now
  727.         lists all the PAGE_xx ranges when I specify an import.
  728.  
  729.  
  730.  
  731.  
  732.  
  733.                                         10
  734.  
  735.                                                        123-Write ver 2.0
  736.                                     Copyright (c) 1990, Thomas J. Vought
  737.  
  738.         File  viewers  are another matter.  Lotus's Magellan,  I've  been
  739.         told,  displays  the file as expected, but  other  viewers  don't
  740.         display  the whole file.  I believe this may be because the  demo
  741.         writes cells in a 'some here, some there' manner, rather then the
  742.         row  by row, col by col sequence, and the viewer just  loses  it,
  743.         and displays as much as it can figure out.
  744.  
  745.         Last  item  is the results of the formulas written to  the  file.
  746.         123-Write does not write the result of a formula to the file,  as
  747.         a spreadsheet would, but just writes the formula.  When the  file
  748.         is  loaded, the spreadsheet does a calculation on all cells,  and
  749.         you  never see the zero 'results'.  Not true with an import to  a
  750.         word processor or a file viewer.  Don't be alarmed if the  result
  751.         of  all  your  hard work appears to be  nothing  but  zeros  when
  752.         'viewed' or imported to a word processor.  A File Retrieve,  File
  753.         Save  sequence is all that should be needed to make your  spread-
  754.         sheet file more conformist.
  755.  
  756.         Bottom line is, I feel the flexibility afforded is more important
  757.         then compatibility with products other than spreadsheet programs.
  758.         A perfect example is when reading from a file to create a spread-
  759.         sheet.  You don't know in advance the cells that are going to  be
  760.         in  a range, so you can't stick the range name definition at  the
  761.         start  of the spreadsheet file.  123-Write allows you  to  define
  762.         the range after the imput file is read and written to the spread-
  763.         sheet file, once the variable boundaries of the range are known.
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.                                         11
  795.  
  796.                                                        123-Write ver 2.0
  797.                                     Copyright (c) 1990, Thomas J. Vought
  798.  
  799.         DEFAULT SETTINGS with lFileOpen.
  800.  
  801.         When a worksheet file is opened with lFileOpen, one of two condi-
  802.         tions will dictate the default settings of the worksheet.  Either
  803.         the  call is the first one to open a spreadsheet file  (lFileOpen
  804.         or  lFileAppend) in the current program, or a subsequent call  to
  805.         lFileOpen in the same program:
  806.  
  807.              Setting:                 First Open:         Subsequent:
  808.              ---------                -----------         -----------
  809.              Calc Iterations:         1                   1
  810.              Calc Mode:               Auto                Auto
  811.              Calc Order:              Natural             Natural
  812.  
  813.              Global Protection:       Off                 Off
  814.  
  815.              Printing:                Formatted           Formatted
  816.                Left margin:           4                   4
  817.                Right margin:          76                  76
  818.                Top Margin:            2                   2
  819.                Bottom Margin:         2                   2
  820.                Lines per Page:        66                  66
  821.  
  822.              Hidden Columns:          None                None
  823.  
  824.              Lotus Default:
  825.                Cell Format:           Default             Default   Note1
  826.                Label alignment:       '(left)             '(left)   Note2
  827.  
  828.              123-Write Default:
  829.                Cell Format:           Protected-Default   Last setting.
  830.                Label alignment:       '(left)             Last setting.
  831.                Date Format:           dd-mmm-yy (D1)      Last setting.
  832.                Time Format:           hh:mm:ss AM/PM      Last setting.
  833.  
  834.         NOTE1:    The Lotus "Default" is a unique cell format setting.
  835.                   What form it takes, and the cells that are marked with
  836.                   it, is the format selected with the "/Worksheet Global
  837.                   Format" command.  This format can be selected with the
  838.                   lSetCellForm routine.
  839.  
  840.         NOTE2:    The Lotus  "Default"  label alignment,  as used here,
  841.                   refers  only to  what alignment  text typed  into the
  842.                   worksheet  while in  Lotus will  take on.   It is not
  843.                   changeable with .
  844.  
  845.         The 123-Write formats determine what format 123-Write will speci-
  846.         fy  for cells it writes.  Every cell written has a format  speci-
  847.         fied.  The label alignment 123-Write default can be overridden by
  848.         including a label prefix character in the string that is  written
  849.         to the cell.  See lWriteStr for more information.
  850.  
  851.  
  852.  
  853.  
  854.  
  855.                                         12
  856.  
  857.                                                        123-Write ver 2.0
  858.                                     Copyright (c) 1990, Thomas J. Vought
  859.  
  860.         DEFAULT SETTINGS with lFileAppend.
  861.  
  862.         The  first consideration here has to be the fact that  the  work-
  863.         sheet  file is set with the defaults in effect when it  was  last
  864.         written.   That could be either the way it was when you wrote  it
  865.         with 123-Write, or the settings made to it in Lotus 1-2-3, before
  866.         it was saved to disk from Lotus.
  867.  
  868.         That fact precludes a list of what settings are in effect as  far
  869.         as  global worksheet defaults.  However, the following  123-Write
  870.         defaults can be relied on.
  871.  
  872.         "First Append" refers to the first time your program opens a file
  873.         (either  lFileOpen or lFileAppend) for append,  and  "subsequent"
  874.         refers to opens for appends while your program is still  running,
  875.         whether it's the same file or a different file:
  876.  
  877.              Setting:                 First Append:       Subsequent:
  878.              ---------                -----------         -----------
  879.              Hidden Columns:          None                None
  880.  
  881.              123-Write Default:
  882.                Cell Format:           Protected-Default   Last setting.
  883.                Label alignment:       '(left)             Last setting.
  884.                Date Format:           dd-mmm-yy (D1)      Last setting.
  885.                Time Format:           hh:mm:ss AM/PM      Last setting.
  886.  
  887.  
  888.         What  all  this boils down to, is that the above  "Last  Setting"
  889.         items are not changed it they've already been set, otherwise they
  890.         are set to the default conditions shown.
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.                                         13
  917.  
  918.                                                        123-Write ver 2.0
  919.                                     Copyright (c) 1990, Thomas J. Vought
  920.  
  921.         SOME GUIDELINES:
  922.  
  923.         Things to remember when coding calls:
  924.  
  925.         All  CALLs that take numeric parameters use 2 byte  signed  inte-
  926.         gers,  except for lWriteNum, which takes one double  precision  8
  927.         byte  real  value, and lConstMath where the constant  is  also  a
  928.         double precision 8 byte real variable.
  929.  
  930.         All cell references in Lotus are 0 based.  Column A is column  0,
  931.         and row 1 is row 0.  Clear as mud right?  Well, just remember  to
  932.         subtract  one  from what you think of the row number as.  If  you
  933.         count columns on your fingers like I do, the first finger is 'B'.
  934.         All  the routines that need column and row numbers use the  Lotus
  935.         zero  based references.  lCol is a function (remember to  DECLARE
  936.         it  as an INTEGER function in your program if you use  it.)  that
  937.         will  return the zero based column number when called with a  one
  938.         or  two byte string.  See the entry for lCol for an example.   It
  939.         relieves the strain of counting on your fingers.
  940.  
  941.         Now an important point.  The logic in these routines (if any)  is
  942.         based on a left to right, top to bottom sequence. This  simulates
  943.         the printing of a report.
  944.  
  945.         Every  time a routine is called that writes data to a  cell,  the
  946.         cell pointer is:
  947.  
  948.              Increased by one column if the write is successful, the row
  949.              stays the same.
  950.  
  951.              May not be increased if there is an error detected.
  952.  
  953.              May move the pointer after an error is detected, because
  954.              the Lotus function @ERR is written to the cell.
  955.  
  956.              Won't move the cell pointer, because there is no cell data
  957.              written.  lGlobal and lSetCol are examples.
  958.  
  959.              If you should attempt to write a cell beyond the 255th, (IV)
  960.              the routines will increment the row and return to column
  961.              0 (column A).
  962.  
  963.         Each  routines' description will describe what actions are  taken
  964.         for errors, out of range paramters, etc.
  965.  
  966.         When printing to the printer or screen, you allow for line feeds,
  967.         in 123-Write, the lLineFeed routine serves the same purpose.  The
  968.         row is increased  and the column returns to  0.
  969.  
  970.         Another  point  is  when using the  'cursor  movement'  routines,
  971.         lLeft/lRight/lUp/lDown.  If you have just written to cell A5  for
  972.         example, which is column 0, row 4, and call lUp(4) to move up  to
  973.         row  0, you will be in column B (1).  The cell pointer was  moved
  974.         one  column to the right after A5 was written.   Some  allowances
  975.  
  976.  
  977.                                         14
  978.  
  979.                                                        123-Write ver 2.0
  980.                                     Copyright (c) 1990, Thomas J. Vought
  981.         for the column increments upon cell writing have to be calculated
  982.         in.
  983.  
  984.         Where Am I in this 'SpreadSheet' anyway?
  985.  
  986.         The  answer  to that depends upon how the  spreadsheet  file  was
  987.         opened.   If  it's a new spreadsheet file  (lFileOpen)  then  the
  988.         column pointer is set to column 0 (A) and the row pointer is  set
  989.         to row 0 (1) when the file is opened.  The {HOME} position there-
  990.         fore, is the first cell written, then 1,0 (B1), then 2,0 (C1).  A
  991.         CALL  to  lLineFeed at this point would mean that the  next  cell
  992.         written would be 0,1 (A2), then 1,1 (B2) etc.  It takes a  little
  993.         getting used to, but it works well.
  994.  
  995.         If  the file was opened with lFileAppend, then the  cell  pointer
  996.         will be set to the {end}{home} position.  This cell is the bottom
  997.         right corner of the spreadsheet.  It may very well contain  data,
  998.         so  the first thing after calling lFileAppend you need to  do  is
  999.         position  the cell pointer to where you want the  next stream  of
  1000.         data to be written.
  1001.  
  1002.         There are routines to get the current location of the cell point-
  1003.         er and to set the location of the cell pointer.
  1004.  
  1005.         First  lGetLoc(whereAmIcol%,  whereAmIrow%) returns  the  current
  1006.         cell  pointer  column  and row coordinates, and then  a  call  to
  1007.         lSetLoc(nextCol%, nextRow%)  will adjust the cell pointer.
  1008.  
  1009.         What's new?
  1010.  
  1011.         This  is  not  meant to be a substitute for  reading  the  entire
  1012.         manual  if  you've used previous versions of 123-Write.   I  have
  1013.         tried to make version 2 quite a bit more comprehensive, and a lot
  1014.         of the calling syntax has been changed from version 1.0 and 1.1.
  1015.         That's why I've changed every routine's name.
  1016.  
  1017.         Three  reported  bugs in version 1.0 were  corrected  in  version
  1018.         1.1a/b, and or 2.0.
  1019.  
  1020.         The  lDate routine choked on a date delimited by  slashes.   That
  1021.         was corrected in 1.1a/b so a dash "-" or a slash "/" was OK.  New
  1022.         feature (??) in 2.0, is that the delimiter is ignored altogether!
  1023.         Calculations  are based on the length of the string passed, so  a
  1024.         little more work is on your shoulders.  See the entries for  both
  1025.         lDate and lTime for more information.
  1026.  
  1027.         The second was a MAJOR bug in the 1.0 LotusWriteStr routine.  The
  1028.         code attempted to test the second character of the string  passed
  1029.         to the routine {ie: MID$(data$,2,1)} when a test of the  string's
  1030.         length  hadn't verified it was at least two bytes long.   A  real
  1031.         easy one, and it shouldn't have been there, but the easy bugs are
  1032.         the ones you don't (at least I miss them) plan and test for.   My
  1033.         apologies on this one.
  1034.  
  1035.  
  1036.  
  1037.  
  1038.                                         15
  1039.  
  1040.                                                        123-Write ver 2.0
  1041.                                     Copyright (c) 1990, Thomas J. Vought
  1042.  
  1043.         The last one was an annoyance, the string passed to LotusWriteStr
  1044.         (ver  1.0)  was modified if it did not contain  a  leading  label
  1045.         prefix  character.   The  routine would prefix  the  passed  data
  1046.         string  with the default label prefix character and  that  string
  1047.         got returned modified.  The lWriteStr routine now manipulates the
  1048.         string internally and won't modify the string passed to it.
  1049.  
  1050.         Version 2.0:
  1051.  
  1052.         At  this point I'm so muddled from converting everything over  to
  1053.         assembly  language, I'm sure I won't cover all the changes.   Off
  1054.         the top of my head:
  1055.  
  1056.         lBoolean  Sub program added.  Allows you to use the Lotus #AND#,
  1057.                   #OR#, #NOT# operators, and equal, not equal, less than
  1058.                   greater than etc.
  1059.  
  1060.         lCellFunction
  1061.                   Now supports all 92 of the Release 2.2 @functions.
  1062.                   Range, data base and mixed references have been added
  1063.                   to the cell functions.
  1064.  
  1065.         lColFunc  Both routines have had the @STD and @VAR functions
  1066.           and     added.  Also, the lColFunction can use @ROWS and the
  1067.         lRowFunc  lRowFunction can use @COLS.
  1068.  
  1069.         lConstMath
  1070.                   Now allows you to reverse the order of the constant
  1071.                   and cell reference.
  1072.  
  1073.         lHideCol  Added to allow you specify hidden columns.
  1074.  
  1075.         lLink     Added to use the Release 2.2 spreadsheet file linking
  1076.                   feature.
  1077.  
  1078.         lPrintBorders
  1079.                   Has been modified to allow the one cell 'A1' to be
  1080.                   designated as a border row or border column.
  1081.  
  1082.         lSetCellForm
  1083.                   Has been revised to allow setting of all possible cell
  1084.                   formats, including +/-, general, hidden and default.
  1085.  
  1086.         lTimeNow  Added to write the @NOW formula to a cell in a time
  1087.                   display format.
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.                                         16
  1100.  
  1101.                                                        123-Write ver 2.0
  1102.                                     Copyright (c) 1990, Thomas J. Vought
  1103.  
  1104.         Again,  many of the parameters passed to the routines in  version
  1105.         2.0  have  been  changed, and I have to ask that  you  scan  this
  1106.         manual and your code carefully for any changes.  Finally, version
  1107.         2.0  of 123-Write is not intended to be backward compatible  with
  1108.         earlier  versions.   I attempted to keep the  calling  syntax  as
  1109.         close  as possible with 1.0 and 1.1 versions  wherever  possible.
  1110.         With  the need for additional error information to be  passed,  I
  1111.         felt  that  it  would be better to use  different  routine  names
  1112.         altogether.  Therefore, if you're upgrading, please don't attempt
  1113.         to  use a search and replace on the "Lotus" that all the  version
  1114.         1.x routine names used, and leave it at that.  Use the  123W20.BI
  1115.         file and be sure to double check the parameter passing sequences.
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.         Detailed  descriptions  of each routine  follow  in  alphabetical
  1123.         order.  All routines begin with L---
  1124.  
  1125.         Error  actions are defined at the end of each routine's  descrip-
  1126.         tion.
  1127.  
  1128.         The  changes made to the cell pointer (CP) are listed   for  each
  1129.         routine, and in each routine's error action section the action is
  1130.         defined as:
  1131.  
  1132.           (CP +)  Cell pointer increased to next column.
  1133.           (CP 0)  Cell pointer not increased.
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.                                         17
  1161.  
  1162.                                                        123-Write ver 2.0
  1163.                                     Copyright (c) 1990, Thomas J. Vought
  1164.  
  1165.         NAME:           lBoolean
  1166.         COMPATIBILITY:  All releases.
  1167.         CELL POINTER:   Increased 1 column.
  1168.  
  1169.         SYNTAX:   lBoolean (col1%, row1%, col2%, row2%, operation%)
  1170.                   col1%     is the column  number of the first cell.
  1171.                   row1%     is the row number of the first cell.
  1172.                   col2%     is the column  number of the second cell.
  1173.                   row2%     is the row number of the second cell.
  1174.  
  1175.                   operation%    indicates the comparison to be performed
  1176.                                 between cell 1 and cell 2.
  1177.  
  1178.                                 Operation codes are:
  1179.  
  1180.                        1    Equal to                      Cell1 =  Cell2
  1181.                        2    Not equal to                  Cell1 <> Cell2
  1182.                        3    Less than or equal to         Cell1 <= Cell2
  1183.                        4    Greater than or equal to      Cell1 >= Cell2
  1184.                        5    Less than                     Cell1 <  Cell2
  1185.                        6    Greater than                  Cell1 >  Cell2
  1186.                        7    AND  (not bitwise)           Cell1#AND#Cell2
  1187.                        8    OR   (not bitwise)            Cell1#OR#Cell2
  1188.                        9    NOT  (not bitwise)            #NOT#Cell1
  1189.  
  1190.         lBoolean  requires two cells to work on, unless the NOT  operator
  1191.         is being used.  With the not operator, the first cell coordinates
  1192.         are  used, the second column/row pair is ignored, but still  must
  1193.         be in the call (use 0,0).
  1194.  
  1195.         Lotus  will return a positive 1 in the cell if the  condition  is
  1196.         true,  a  zero  otherwise for the comparison  set  (operations  1
  1197.         through  6).   The  AND, OR, and NOT functions  are  not  bitwise
  1198.         operators, the following rules are used by Lotus:
  1199.  
  1200.              AND:      If both cells are not zero, returns 1 otherwise
  1201.                        returns 0.
  1202.              OR:       If either cell is not zero, returns 1 otherwise
  1203.                        returns 0.
  1204.              NOT:      If the target cell is zero (false) returns 1,
  1205.                        otherwise will return false, 0.
  1206.  
  1207.         ERRORS:
  1208.              No file open:                 No action taken.
  1209.              Oper% out of range (1-9):     @ERR in current cell. (CP +)
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.                                         18
  1222.  
  1223.                                                        123-Write ver 2.0
  1224.                                     Copyright (c) 1990, Thomas J. Vought
  1225.  
  1226.         NAME:           lCellFunction
  1227.         COMPATIBILITY:  Various, see table page 21.
  1228.         CELL POINTER:   Increased 1 column.
  1229.  
  1230.         SYNTAX:   lCellFunction(dSeg%, dOfs%)
  1231.  
  1232.                   dSeg%     is the VARSEG() of the first element of an
  1233.                             integer array, or a user defined TYPE.
  1234.                   dOfs%     is the VARPTR() of the first element of an
  1235.                             integer array, or a user defined TYPE.
  1236.  
  1237.         lCellFunction writes a specified Lotus @ function to the  current
  1238.         cell.  All 92 of release 2.2's @ functions are supported.
  1239.  
  1240.         Multiple functions can't be combined, the alternative is to write
  1241.         the components of the multiple functions to out of the way cells,
  1242.         and operate on them in steps.
  1243.  
  1244.         The routine expects the far address of an integer array or a user
  1245.         defined type that is made up of only integers.
  1246.  
  1247.         The  first element indicates the function to perform.   With  the
  1248.         exception of the @CHOOSE function, the second through x  elements
  1249.         are pairs of col/row co-ordinates.  The function requested deter-
  1250.         mines  what is to follow.  Some functions operate on one  or  two
  1251.         absolute  cells, some on ranges, and some mix ranges  and  cells.
  1252.         See  the Lotus documentation for the correct sequences of  opera-
  1253.         tors required for each @function.
  1254.  
  1255.         When  using the @CHOOSE function, number 18, the  second  element
  1256.         indicates  the  number of absolute cell references  that  follow,
  1257.         then the column, row co-ordinates for each cell.
  1258.  
  1259.         When  using an integer array, DIMed as array%(1 TO 12) for  exam-
  1260.         ple,  you  could set up a call to write the @IF function  to  the
  1261.         current cell as:
  1262.  
  1263.                   array%(1) = 29           'Function 29 is @IF(
  1264.                   array%(2) =  0           'Col A    Test cell: A1
  1265.                   array%(3) =  0           'Row 1
  1266.                   array%(4) =  2           'Col C    A1 <> 0? :   C4
  1267.                   array%(5) =  3           'Row 4
  1268.                   array%(6) =  4           'Col E    A1 = 0?  :      E6)
  1269.                   array%(7) =  5           'Row 6
  1270.                   CALL lCellFunction(VARSEG(array%(1)),VARPTR(array%(1))
  1271.  
  1272.         Would result in:  @IF(A1,C4,E6)   in the current worksheet cell.
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.                                         19
  1283.  
  1284.                                                        123-Write ver 2.0
  1285.                                     Copyright (c) 1990, Thomas J. Vought
  1286.  
  1287.         lCellFunction   (continued)
  1288.  
  1289.              You could use a TYPE'd variable instead of an array:
  1290.  
  1291.         TYPE functionType
  1292.            fCode    AS INTEGER
  1293.            col1     AS INTEGER
  1294.            row1     AS INTEGER
  1295.            col2     AS INTEGER
  1296.            row2     AS INTEGER
  1297.            col3     AS INTEGER
  1298.            row3     AS INTEGER
  1299.            col4     AS INTEGER
  1300.            row4     AS INTEGER
  1301.         END TYPE
  1302.  
  1303.         DIM func AS FunctionType
  1304.  
  1305.              func.fCode = 85                '85 = @RATE, requires 3 cells
  1306.              func.col1 = 0                  ;Col A
  1307.              func.row1 = 0                  ;Row 1
  1308.              func.col2 = 2                  ;Col C
  1309.              func.row2 = 3                  ;Row 4
  1310.              func.col3 = 4                  ;Col E
  1311.              func.row3 = 5                  ;Row 6
  1312.              CALL lCellFunction(VARSEG(func),VARPTR(func))
  1313.  
  1314.         Results  in: @RATE(A1,C4,E6) being written to the  current  work-
  1315.         sheet cell.
  1316.  
  1317.         In  the  table  on the following page, each  function  is  listed
  1318.         alphabetically.   The  individual 123-Write  function  number  is
  1319.         listed  first,  the Lotus @ function, then the  number  of  cells
  1320.         needed, followed by the type of parameter and Lotus version.  The
  1321.         number  of cells varies by parameter type.  The  parameter  types
  1322.         are  variables   (cells), ranges, mixed  parameters  or  database
  1323.         parameters.  The parameter type codes are:
  1324.  
  1325.              V    a variable, which is a cell address.  Requires an
  1326.                   integer column number then an integer row for each
  1327.                   variable.  Maximum is 4, which would need an integer
  1328.                   array of 9 elements (Function #, c1, r1,...c4, r4)
  1329.  
  1330.              R    a range, which is two cell addresses, the upper left
  1331.                   corner cell, then the lower right corner cell.  Those
  1332.                   functions that are marked R only require one range
  1333.                   maximum, so a 5 element array will handle them:
  1334.                   Function #, upLeftCol, upLeftRow, lowRcol, lowRrow.
  1335.  
  1336.              D    a database function parameter. These take the form of
  1337.                   input range, offset cell, criteria range, so a 10
  1338.                   element array is needed.
  1339.  
  1340.  
  1341.  
  1342.  
  1343.                                         20
  1344.  
  1345.                                                        123-Write ver 2.0
  1346.                                     Copyright (c) 1990, Thomas J. Vought
  1347.  
  1348.         ##   @Function   Pass Type Ver    ##  @Function    Pass Type Ver
  1349.         ------------------------------------------------------------------
  1350.         84 =  @@           1   V   20     74 =  @LEFT        2   V   20
  1351.          3 =  @ABS         1   V   1a     40 =  @LENGTH      1   V   20
  1352.         15 =  @ACOS        1   V   1a      7 =  @LN          1   V   1a
  1353.         14 =  @ASIN        1   V   1a      6 =  @LOG         1   V   1a
  1354.         13 =  @ATAN        1   V   1a     73 =  @LOWER       1   V   20
  1355.         12 =  @ATAN2       2   V   20     54 =  @MAX         1   R   1a
  1356.         51 =  @AVG         1   R   1a     43 =  @MID         3   V   20
  1357.         78 =  @CELL        3   M*  20     53 =  @MIN         1   R   1a
  1358.         49 =  @CELLPOINTER 1   V   20     36 =  @MINUTE      1   V   20
  1359.         44 =  @CHAR        1   V   20     17 =  @MOD         2   V   1a
  1360.         18 =  @CHOOSE      ?   V   1a     31 =  @MONTH       1   V   1a
  1361.         80 =  @CLEAN       1   V   20     82 =  @N           1   R   20
  1362.         45 =  @CODE        1   V   20      1 =  @NA          0       1a
  1363.         69 =  @COLS        1   R   20     25 =  @NOW/TODAY   0       1a
  1364.         10 =  @COS         1   V   1a     56 =  @NPV         3   M*  1a
  1365.         52 =  @COUNT       1   R** 20      8 =  @PI          0       1a
  1366.         87 =  @CTERM       3   V   20     26 =  @PMT         3   V   1a
  1367.         24 =  @DATE        3   V   1a     77 =  @PROPER      1   V   20
  1368.         47 =  @DATEVALUE   1   V   20     27 =  @PV          3   V   1a
  1369.         62 =  @DAVG        5   D   1a     23 =  @RAND        0       1a
  1370.         30 =  @DAY         1   V   1a     85 =  @RATE        3   V   20
  1371.         63 =  @DCOUNT      5   D   1a     71 =  @REPEAT      2   V   20
  1372.         90 =  @DDB         4   V   20     76 =  @REPLACE     4   V   20
  1373.         65 =  @DMAX        5   D   1a     75 =  @RIGHT       2   V   20
  1374.         64 =  @DMIN        5   D   1a     33 =  @ROUND       2   V   1a
  1375.         67 =  @DSTD        5   D   1a     70 =  @ROWS        1   R   20
  1376.         61 =  @DSUM        5   D   1a     81 =  @S           1   R   20
  1377.         66 =  @DVAR        5   D   1a     37 =  @SECOND      1   V   20
  1378.          2 =  @ERR         0       1a      9 =  @SIN         1   V   1a
  1379.         83 =  @EXACT       2   V   20     88 =  @SLN         3   V   20
  1380.         16 =  @EXP         1   V   1a      5 =  @SQRT        1   V   1a
  1381.         21 =  @FALSE       0       1a     58 =  @STD         1   R   1a
  1382.         46 =  @FIND        3   V   20     42 =  @STRING      2   V   20
  1383.         28 =  @FV          3   V   1a     50 =  @SUM         1   R   1a
  1384.         60 =  @HLOOKUP     4   M*  20     89 =  @SYD         4   V   20
  1385.         35 =  @HOUR        1   V   20     11 =  @TAN         1   V   1a
  1386.         29 =  @IF          3   V   1a     86 =  @TERM        3   V   20
  1387.         68 =  @INDEX       4   M*  20     34 =  @TIME        3   V   20
  1388.          4 =  @INT         1   V   1a     48 =  @TIMEVALUE   1   V   20
  1389.         59 =  @IRR         3   M*  1a     79 =  @TRIM        1   V   20
  1390.         91 =  @ISAAF       1   V   22     22 =  @TRUE        0       1a
  1391.         92 =  @ISAPP       1   V   22     72 =  @UPPER       1   V   20
  1392.         20 =  @ISERR       1   V   1a     41 =  @VALUE       1   V   20
  1393.         19 =  @ISNA        1   V   1a     57 =  @VAR         1   R   1a
  1394.         38 =  @ISNUMBER    1   V   20     55 =  @VLOOKUP     4   M*  20
  1395.         39 =  @ISSTRING    1   V   20     32 =  @YEAR        1   V   1a
  1396.  
  1397.         * M = Mixed, See specific format on next page.
  1398.         ** See note next page.
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.                                         21
  1405.  
  1406.                                                        123-Write ver 2.0
  1407.                                     Copyright (c) 1990, Thomas J. Vought
  1408.  
  1409.         For the Mixed parameter functions on the previous page:
  1410.  
  1411.         @HLOOKUP
  1412.         @VLOOKUP  require a cell, range, cell format.  9 elements.
  1413.  
  1414.         @CELL
  1415.         @IRR
  1416.         @NPV      require a cell, followed by a range.  7 elements.
  1417.  
  1418.         @INDEX    requires a range, cell, and cell.  9 elements.
  1419.  
  1420.         @COUNT    is coded to expect a range only.  Cell lists and the
  1421.                   other optional entries allowed in Lotus are not
  1422.                   supported in 123-Write.
  1423.  
  1424.         Note  that  those functions that work on strings  should  have  a
  1425.         variable  that  points  to a cell containing a  string.   If  the
  1426.         variable portion of the function is not of the correct type,  the
  1427.         cell to which the function is written will display "ERR" and that
  1428.         error can propagate through other dependent cells.
  1429.  
  1430.         For example, @@(cell) returns the value in the cell specified  in
  1431.         "cell".  So the cell referred to should have a string cell  name,
  1432.         such as 'A6.
  1433.  
  1434.         The @CELLPOINTER("cell") and @CELL("cell") functions, expect  the
  1435.         parameter to be something like: CONTENTS, PREFIX, FORMAT etc.  So
  1436.         the  cell  that  is supplied as a parameter  should  contain  the
  1437.         string:  'CONTENTS or 'PREFIX or 'FORMAT etc.
  1438.  
  1439.         With  Lotus  release 2 and greater, it is possible to  work  with
  1440.         cells  that contain strings.  For example, if cell C23  contained
  1441.         "Hello World" then any cell that had the formula +C23 would  also
  1442.         display "Hello World".  Formulas like this in release 1A  though,
  1443.         will not transfer the string, they expect a numeric argument, and
  1444.         will display 0 as the result.  Any string cell in release 1A  are
  1445.         considered to be equal to zero.  Look at the @CHOOSE function  in
  1446.         the demo for an example if you write a 1a compatible file.
  1447.  
  1448.         Don't forget that BASIC can and will move data around in  memory.
  1449.         The  segment and offset of a particular data item is  not  always
  1450.         static.   Don't  try  to use variables to hold  the  segment  and
  1451.         offset of a structure for a later call.  I'm especially  cautious
  1452.         on  this point, and always embed the VARSEG and VARPTR  functions
  1453.         into  CALLs  that  use segment and offset addresses,  as  in  the
  1454.         examples for this routine.
  1455.  
  1456.  
  1457.         ERRORS:
  1458.              No file open:                 No action taken.
  1459.              Oper% out of range (1-9):     @ERR in current cell. (CP +)
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.                                         22
  1466.  
  1467.                                                        123-Write ver 2.0
  1468.                                     Copyright (c) 1990, Thomas J. Vought
  1469.  
  1470.         NAME:           lCellMath
  1471.         COMPATIBILITY:  All releases.
  1472.         CELL POINTER:   Increased 1 column.
  1473.  
  1474.         SYNTAX:   lCellMath(col1%, row1%, col2%, row2%, oper%)
  1475.  
  1476.                   col1%     is the column number of the 1st cell the
  1477.                             math is to be performed on.
  1478.                   row1%     is the row number of the 1st cell the
  1479.                             math is to be performed on.
  1480.                   col2%     is the column number of the 2nd cell the
  1481.                             math is to be performed on.
  1482.                   row2%     is the row number of the 2nd cell the
  1483.                             math is to be performed on.
  1484.                   oper%     is one of the following:
  1485.  
  1486.                             1    add cell 1 and cell 2.
  1487.                             2    subtract cell 2 from cell 1.
  1488.                             3    multiplication of cells 1 and 2.
  1489.                             4    Division of cell 1 by cell 2.
  1490.                             5    Cell 1 raised to the power of cell 2.
  1491.  
  1492.         lCellMath  provides  simple math operations on  two  cells.   Any
  1493.         function numbers outside the range 1 through 5 will result in the
  1494.         target cell being tagged with @ERR.
  1495.  
  1496.         EXAMPLE:  col1 = 0                        'A
  1497.                   row1 = 2                        '3
  1498.                   col2 = 8                        'I
  1499.                   row2 = 5                        '6
  1500.                   oper = 3                        'Multiply
  1501.  
  1502.                   CALL lCellMath(col1%, row1%, col2%, row2%, oper%)
  1503.  
  1504.         Will multiply A3 by I6 and place the formula in the current cell.
  1505.  
  1506.  
  1507.         ERRORS:
  1508.              No file open:                 No action taken.
  1509.              Oper% out of range (1-5):     @ERR in current cell. (CP +)
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.                                         23
  1527.  
  1528.                                                        123-Write ver 2.0
  1529.                                     Copyright (c) 1990, Thomas J. Vought
  1530.  
  1531.         NAME:           lClose
  1532.         COMPATIBILITY:  All releases.
  1533.         CELL POINTER:   N/A
  1534.  
  1535.         SYNTAX:   lClose
  1536.  
  1537.         Closes  the  currently open spreadsheet file  after  writing  the
  1538.         Lotus  end of file marker and updating the worksheet  range.  The
  1539.         worksheet range is the cell that results from the {END}{HOME} key
  1540.         presses in Lotus.
  1541.  
  1542.         A  general  CLOSE statement in your program will  NOT  close  the
  1543.         spreadsheet  file.   This differs from the 1.x versions  of  123-
  1544.         Write which were written in BASIC.
  1545.  
  1546.         Note  that  all the routines in this library keep  track  of  the
  1547.         spreadsheet file handle internally.  lClose resets the handle  to
  1548.         0 and all the routines that write to the file naturally check for
  1549.         a  valid  handle before an attempt is made to write data  to  the
  1550.         file.  Calling a routine when there is no file open, or the  file
  1551.         wasn't  opened  via lFileOpen or lFileAppend, will  not  cause  a
  1552.         crash  because the internal handle is checked.  However,  if  you
  1553.         fail to close the file with this routine, three things are possi-
  1554.         ble/probable:
  1555.  
  1556.         1.   Subsequent  calls  to lFileOpen  or  lFileAppend  will  fail
  1557.         because the internal handle still indicates a file open.
  1558.  
  1559.         2.  The disk's directory will not be updated properly.  One  file
  1560.         handle  from DOS's pool will not be available to subsequent  pro-
  1561.         grams until the machine is rebooted.
  1562.  
  1563.         3.    Lotus will beep and issue a "Part of file  missing."  error
  1564.         when the spreadsheet loads.  Definitely not a reassuring  happen-
  1565.         stance.
  1566.  
  1567.         Very  little  error checking is done in the  123-Write  routines.
  1568.         It's your job to debug your mainline code so the file is properly
  1569.         opened and closed.  When in the QB or QBX environment, lClose  is
  1570.         called if there is a file open and your program terminates abnor-
  1571.         mally  or you respond "OK" to one of QB's "You will have  to  re-
  1572.         start your program after this edit" prompts.
  1573.  
  1574.  
  1575.         EXAMPLE:       CALL lClose
  1576.  
  1577.         ERRORS:
  1578.              No file open:                 No action taken.
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.                                         24
  1588.  
  1589.                                                        123-Write ver 2.0
  1590.                                     Copyright (c) 1990, Thomas J. Vought
  1591.  
  1592.         NAME:           lCol
  1593.         COMPATIBILITY:  All releases.
  1594.         CELL POINTER:   Not changed.
  1595.  
  1596.         SYNTAX:   lCol (column$)
  1597.  
  1598.                   column$        is a one or two byte string.
  1599.  
  1600.  
  1601.         lCol is a FUNCTION, and as such must be declared in your  program
  1602.         as  an INTEGER function before any calls are made to it.   Other-
  1603.         wise the compiler will treat it as an array reference.
  1604.  
  1605.         lCol  returns the zero based column number for the  corresponding
  1606.         column$, if column$ is a valid representation of a Lotus  column.
  1607.         It must be between "A" and "IV".  If the string is invalid,  lCol
  1608.         will return a value of -1.
  1609.  
  1610.         The  reason lCol is a FUNCTION rather than a sub program,  is  so
  1611.         that  it  can  be used in calls that require  an  integer  column
  1612.         number.   You may notice I make liberal use of this  function  in
  1613.         the demo program.  In reality however, I would use this  function
  1614.         only  where a real variable would come into use.  The INPUT of  a
  1615.         column  letter in the demo is an example.  Otherwise as I  debug,
  1616.         I'd  stick  a stop statement after the function  call,  get  it's
  1617.         result and use that value in the finished code for speed.
  1618.  
  1619.  
  1620.         EXAMPLE:
  1621.              DECLARE FUNCTION lCol%(a$)
  1622.              .
  1623.              .
  1624.              x = lCol ("AB")
  1625.              '  x should be equal to 27.  (A-Z) = 26
  1626.              '                          + (A-B) =  2
  1627.              '                      - Zero Base = -1
  1628.              '                                 -----
  1629.              '                                    27
  1630.  
  1631.         See examples under lSetLoc and lSetCol also.
  1632.  
  1633.         NOTE:
  1634.            I  keep a PRINT lCOL("  ") line in the immediate window  while
  1635.         working in QB.  That way, when coding, I can just hit F6, fill in
  1636.         the column, see the result and code the proper number into  other
  1637.         call statements.
  1638.  
  1639.         ERRORS:
  1640.              No file open:           OK, returns the column number.
  1641.              Out of range (A-IV):    Returns -1 as column number. (CP 0)
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.                                         25
  1649.  
  1650.                                                        123-Write ver 2.0
  1651.                                     Copyright (c) 1990, Thomas J. Vought
  1652.  
  1653.         NAME:           lColFunction
  1654.         COMPATIBILITY:  All releases, except @ROWS, ver 2.0+
  1655.         CELL POINTER:   Increased one column.
  1656.  
  1657.         SYNTAX:   lColFunction (startRow%, endRow%, oper%)
  1658.  
  1659.                   startRow%      represents the first row to operate on.
  1660.                   endRow%        represents the last row to operate on.
  1661.                   oper%          is set to one of the following:
  1662.  
  1663.                             1.   @SUM the sum of the cells.
  1664.                             2.   @AVG the average of the cells.
  1665.                             3.   @COUNT the count of cells with
  1666.                                         valid data.
  1667.                             4.   @MIN the lowest value in the range.
  1668.                             5.   @MAX the highest value in the range.
  1669.                             6.   @STD the stnd deviation of the range.
  1670.                             7.   @VAR the variance of the range.
  1671.                             8.   @ROWS the count of the rows, inclusive.
  1672.  
  1673.         lColFunction  is a quick method of writing common columnar  func-
  1674.         tions  to a cell, or a series of cells.  The routine assumes  the
  1675.         column to operate on is the current column, so all that's  needed
  1676.         in  the  call  is the first row to include and the  last  row  to
  1677.         include.  You can set the cell pointer with lSetLoc if needed.
  1678.  
  1679.         An  example  is probably the best way to  illustrate.   Lets  say
  1680.         you're  writing  a  spreadsheet where the first  three  rows  are
  1681.         titles  and column headings etc.  The first valid data row is  3,
  1682.         and  you have 4 columns of data, 0 through 3 (A through D).   The
  1683.         number  of  rows of data vary based on the database  file  you're
  1684.         reading, so you don't have a fixed ending row when the program is
  1685.         run.  Code would look something like this:
  1686.  
  1687.                   FOR i = 1 TO LOF(dataFile%) \ LEN(dataRecord%)
  1688.                        ...writing a row loop...
  1689.                        CALL lLineFeed      'Get set for next row.
  1690.                   NEXT i
  1691.  
  1692.                   'after the last data item is written, your row pointer
  1693.                   'is one below the last row of data, and your column
  1694.                   'will be 0 (A) so:
  1695.  
  1696.                   CALL lGetLoc(currentCol%, currentRow%)
  1697.                   endRow% = currentRow% - 1
  1698.  
  1699.                   FOR i = 0 TO 3
  1700.                        CALL lColFunction(3, endRow%, 1)    '@SUM
  1701.                   NEXT
  1702.  
  1703.         ERRORS:
  1704.              No file open:                 No action taken.
  1705.              Oper% out of range (1-8):     @ERR in current cell. (CP +)
  1706.  
  1707.  
  1708.  
  1709.                                         26
  1710.  
  1711.                                                        123-Write ver 2.0
  1712.                                     Copyright (c) 1990, Thomas J. Vought
  1713.  
  1714.         NAME:           lConstMath
  1715.         COMPATIBILITY:  All releases.
  1716.         CELL POINTER:   Increased one column.
  1717.  
  1718.         SYNTAX:   lConstMath(col%, row%, constVal#, oper%)
  1719.  
  1720.                   col%      is the column number of the cell the math
  1721.                             is to be performed on.
  1722.                   row%      is the row number of the cell the math
  1723.                             is to be performed on.
  1724.                   constVal# is a double precision (8 byte real) value
  1725.                   oper%     is one of the following:
  1726.  
  1727.                             1    add cell and supplied constant.
  1728.                             2    subtract the constant from cell.
  1729.                             3    multiplication of cell by the constant.
  1730.                             4    division of cell by the constant.
  1731.                             5    Cell raised to the power of constant.
  1732.  
  1733.         lConstMath writes a simple math calculation using a cell  address
  1734.         and a constant you supply.  Note that the constant you pass  must
  1735.         be an 8 byte double precision real value.
  1736.  
  1737.         Don't  confuse  the  use of the term constant  with  BASIC's  use
  1738.         (CONST),  a  constant in the Lotus sense is a  hard  number  that
  1739.         won't change. See the example below for how the result would look
  1740.         in Lotus 1-2-3.
  1741.  
  1742.         If  the operation code you supply is a negative number, then  the
  1743.         order is reversed.  If you called this routine with an  operation
  1744.         code of -2 for example, the cell you specify would be  subtracted
  1745.         from  the constant, instead of the constant subtracted  from  the
  1746.         cell.
  1747.  
  1748.         Operation  values outside the range of -1 to -5 and 1  through  5
  1749.         will result in the target cell being marked @ERR.
  1750.  
  1751.  
  1752.         EXAMPLE:  CALL lConstMath (0, 3, CDBL(5), 4)
  1753.  
  1754.                   will divide the value of cell A2 by 5.
  1755.                   The spreadsheet formula would appear as:
  1756.                           +A2/5
  1757.  
  1758.                   CALL lConstMath (0, 3, CDBL(5), -4)
  1759.  
  1760.                   will divide 5 by the value of cell A2.
  1761.                   The spreadsheet formula would appear as:
  1762.                           5/A2
  1763.  
  1764.         ERRORS:
  1765.              No file open:                 No action taken.
  1766.              Oper% out of range:           @ERR in current cell. (CP +)
  1767.  
  1768.  
  1769.  
  1770.                                         27
  1771.  
  1772.                                                        123-Write ver 2.0
  1773.                                     Copyright (c) 1990, Thomas J. Vought
  1774.  
  1775.         NAME:           lDate
  1776.         COMPATIBILITY:  All releases.
  1777.         CELL POINTER:   Increased one column.
  1778.  
  1779.         SYNTAX:   lDate(dat$)
  1780.  
  1781.                   dat$     is an 8 or 10 byte date string.
  1782.  
  1783.  
  1784.         Writes  the Lotus date value of the date supplied in dat$ to  the
  1785.         current cell.   The value is adjusted to conform with the errone-
  1786.         ous  values 1-2-3 uses.  (Lotus thinks that there was a  February
  1787.         29th of 1900, which is incorrect, 1900 was not a leap year.)  The
  1788.         date string passed should be between 01-01-1900 and 12-31-2099.
  1789.  
  1790.         Useful  for  doing those 30-60-90 day  aging  schedules  everyone
  1791.         seems to need.
  1792.  
  1793.         Only  two  date  formats will convert  properly,  an  eight  byte
  1794.         mm?dd?yy  or  a ten byte mm?dd?yyyy (Basic's) format.   The  only
  1795.         conversion  that is done is to an 8 byte date is to   prefix  the
  1796.         year  with  a "19" or "20" depending on the date the  program  is
  1797.         run.  If the date string passed to the routine cannot be convert-
  1798.         ed  to  a  numeric value, it is written to the cell  as  a  label
  1799.         instead of a number.
  1800.  
  1801.         If a default date format has not been set via a call to lSetDate-
  1802.         Form,  the  target cell is formatted to display the  date  in  D1
  1803.         format.  (dd-mmm-yy) which requires a column width of roughly  10
  1804.         characters.  See the lSetCol & lSetCols routines for  information
  1805.         on setting column widths.
  1806.  
  1807.         The  lDate routine is in LDATE.BAS, and the actual assembly  rou-
  1808.         tines are in two parts.  lDate1 converts a string date to a  long
  1809.         integer value, where 1 equals 01-01-1900.  lDate2 does the actual
  1810.         write of the double precision value to the worksheet file.   Yes,
  1811.         I  couldn't figure out how to do the long to 8 byte real  conver-
  1812.         sion in assembly.  If you think you'd find use for the lDate1 sub
  1813.         program  in  other work, the object file name is  LDATES.OBJ  for
  1814.         regular  strings  and LDATESF.OBJ for far strings.  They  can  be
  1815.         copied out of their respective library files with LIB.EXE.
  1816.  
  1817.         EXAMPLE:       'Date stamp the worksheet file:
  1818.                        CALL lWriteStr("As of:", errCode%)
  1819.                        CALL lDate(DATE$)
  1820.  
  1821.         ERRORS:
  1822.              No file open:                 lDate1: Returns date value.
  1823.                                            lDate2: No action taken.
  1824.              Date not 'convertible':       lDate1: Returns zero.
  1825.                                            lDate2: Writes whatever long
  1826.                                                    integer is passed to
  1827.                                                    it with the current
  1828.                                                    date format.
  1829.  
  1830.  
  1831.                                         28
  1832.  
  1833.                                                        123-Write ver 2.0
  1834.                                     Copyright (c) 1990, Thomas J. Vought
  1835.  
  1836.         NAME:           lDown
  1837.         COMPATIBILITY:  All releases.
  1838.         CELL POINTER:   Increased count% rows.
  1839.  
  1840.         SYNTAX:   lDown(count%)
  1841.  
  1842.                   count%    is the number of rows.
  1843.  
  1844.  
  1845.         lDown  is the equivalent of hitting the down arrow key in  Lotus.
  1846.         The  next  row to be written will be increased by the  number  of
  1847.         rows  the routine is called with.  If your target environment  is
  1848.         Lotus  1-2-3 ver 1a, do not exceed 2047.  The maximum row  number
  1849.         is  8195.  Attempts to 'cursor' down beyond row 8195  will  leave
  1850.         the cursor in row 8195.
  1851.  
  1852.  
  1853.         EXAMPLE:       move% = 5
  1854.                        CALL lDown(move%)
  1855.                        'The next cell to be written will be 5 below the
  1856.                        'current row, in the same column.
  1857.  
  1858.         ERRORS:
  1859.              No file Open:                 No action taken.
  1860.              Count% + current row > 8195:  Cell pointer row set to 8195.
  1861.  
  1862.         (Ver 1a note!  Maximum worksheet row count in 1a was 2047.  lDown
  1863.          will not mind going beyond it.  If you're writing 1a compatible
  1864.          spreadsheets, keep a seperate count to be sure you don't exceed
  1865.          2048 rows.)
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.                                         29
  1893.  
  1894.                                                        123-Write ver 2.0
  1895.                                     Copyright (c) 1990, Thomas J. Vought
  1896.  
  1897.         NAME:           lFileAppend
  1898.         COMPATIBILITY:  All releases.
  1899.         CELL POINTER:   Set to {END}{HOME} position of file.
  1900.  
  1901.         SYNTAX:   lFileAppend(fileName$, ecode%)
  1902.  
  1903.                   fileName$      is a fully qualified file name, that
  1904.                                  may include a drive and path if needed.
  1905.  
  1906.                   ecode%         is returned to indicate an error.
  1907.                                  -1   A spreadsheet file is already open.
  1908.                                  -2   Invalid filespec length.
  1909.                                  -3   DOS version < 2.0  (whew!)
  1910.                                  -4   The specified file is not a Lotus
  1911.                                         123 version 1a, or 2.0+ file.
  1912.  
  1913.                                  Positive  error  codes  indicate  a  DOS
  1914.                                  error,  and are returned  unchanged from
  1915.                                  DOS. An error code of 2 indicates "File
  1916.                                  Not Found".  The error codes in DOS do
  1917.                                  not coincide with BASIC error code
  1918.                                  values however.  See appendix A for some
  1919.                                  that I've come across.
  1920.  
  1921.         Use  lFileAppend to open an existing spreadsheet file and add  on
  1922.         to it.  If your program is running under DOS 3.0 or higher,  then
  1923.         the  file is opened in "Deny All" mode.  If a file  extension  is
  1924.         not specified (no . dot), then a .WKS extension is assumed.
  1925.  
  1926.         Lotus  files need the {end}{home} cell position written early  in
  1927.         the  file,  so  123-Write tracks this  cell  continuously.   When
  1928.         opening  a  spreadsheet file to append data to it,  this  routine
  1929.         will  read as much of the existing file to determine the  current
  1930.         {end}{home} cell as needed, then gets ready to write any data you
  1931.         wish.   The updated {end}{home} cell is written to the file  when
  1932.         lClose is called.
  1933.  
  1934.         The  cellpointer is set to the current {end}{home} cell,  so  the
  1935.         next  cell  to be written after lFileAppend  is  the  {end}{home}
  1936.         cell.   The {end}{home} cell will most likely have valid data  in
  1937.         it,  and the first thing you should do after a call to this  rou-
  1938.         tine  is  position  the cell pointer with a call  to  lSetLoc  or
  1939.         lLineFeed before writing any data to the file.
  1940.  
  1941.         Now  a caution, although a minor one.  It is OK to open  a  file,
  1942.         position  the  cell  pointer to a  previously  written  cell  and
  1943.         'over-write'  the data in that cell.  The thing to keep  in  mind
  1944.         though,  is that the cell is not physically over written  in  the
  1945.         disk  file, but that another entry for that cell is added to  the
  1946.         end  of the file.  This causes no problems with Lotus,  but  I'll
  1947.         throw in an example anyway.
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.                                         30
  1954.  
  1955.                                                        123-Write ver 2.0
  1956.                                     Copyright (c) 1990, Thomas J. Vought
  1957.  
  1958.         lFileAppend (continued)
  1959.  
  1960.         Say you have a worksheet that has your Year to Date Widget  sales
  1961.         in  cell 'A5'.  Your application can determine the year  to  date
  1962.         sales from anywhere of course, and you want it to open the  spre-
  1963.         adsheet and update cell 'A5' whenever it is run.  Let's say  your
  1964.         application  is  run once a week.  You open the  spreadsheet  for
  1965.         append with this routine, call lSetLoc to set the cell pointer to
  1966.         'A5'  and call lWriteNum to write the year to date  widget  sales
  1967.         figure.  Then you close the file and go on your way.
  1968.  
  1969.         Now  let's jump ahead to December when the New Year's Bonus  sub-
  1970.         ject  comes  up,  which is based on year to  date  widget  sales.
  1971.         Amazingly, this is the only time the spreadsheet in question gets
  1972.         loaded.   What will happen, is that Lotus will assign a value  to
  1973.         cell  'A5'  the first time it comes across it in the  file,  then
  1974.         change  the  'A5'  value the next time it reads  it  (your  first
  1975.         update) and continue on, replacing the 'A5' value 52 times.  Your
  1976.         disk  file  also has 52 entries in it for cell 'A5'  which  is  a
  1977.         physical  consideration.  What you will end up with, is the  last
  1978.         year to date widget sales figure in 'A5' which is fine.
  1979.  
  1980.         Now  the  reason I think it's not a major consideration  is  that
  1981.         when the spreadsheet is saved from within Lotus, only the current
  1982.         (last)  value of 'A5' would be saved.  The file size and  loading
  1983.         time would revert back to normal.  Few spreadsheets are ever only
  1984.         read into Lotus and not saved.  On the other hand, if there  were
  1985.         a  large  number of cells being over-written regularly,  and  the
  1986.         spreadsheet  was only for some type of reference, things may  get
  1987.         out  of hand.  A hint would be to write a macro in an out of  the
  1988.         way  place, named '\0' that would save the file as soon  as  it's
  1989.         loaded  into  1-2-3.  The lRange, cell pointer  positioning  rou-
  1990.         tines,  lHideCol, and lWriteStr routines will allow you to  write
  1991.         an invisible macro for just this purpose.
  1992.  
  1993.         ERRORS:
  1994.                 Most (?) will be returned in the errCode% variable.
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.                                         31
  2015.  
  2016.                                                        123-Write ver 2.0
  2017.                                     Copyright (c) 1990, Thomas J. Vought
  2018.  
  2019.         NAME:           lFileOpen
  2020.         COMPATIBILITY:  All releases.
  2021.         CELL POINTER:   Set to 0,0 (Cell A1).
  2022.  
  2023.         SYNTAX:   lFileOpen(fileName$, errCode%)
  2024.  
  2025.                   fileName$      is a fully qualified file name, that
  2026.                                  may include a drive and path if needed.
  2027.  
  2028.                   errCode%       is returned to indicate an error.
  2029.                                  -1   A spreadsheet file is already open.
  2030.                                  -2   File spec is too long or null.
  2031.                                  -3   The current DOS version is less
  2032.                                        than version 2.0.  (Sad)
  2033.  
  2034.                                  Positive error codes indicate a DOS
  2035.                                  error, and are returned unchanged from
  2036.                                  DOS.   The error codes in DOS do not
  2037.                                  coincide with BASIC error code values
  2038.                                  however.  See appendix A for some that
  2039.                                  I've come across.
  2040.  
  2041.  
  2042.         lFileOpen opens a worksheet file for output.  Pass the routine  a
  2043.         valid file name which can include a drive and path if needed.  If
  2044.         DOS  version 3.0 or higher is in use, the file is opened  with  a
  2045.         "Deny All" access code.  No error checking or parsing of the file
  2046.         name  (except for an extension) is done.  You're in charge  here,
  2047.         and  the error codes returned are few.  If the file  already  ex-
  2048.         ists, it will be over written.
  2049.  
  2050.         You  can pass any file name you wish.  If the file name does  not
  2051.         include  an extension, ".WKS" is used by default.   This  routine
  2052.         writes  the  initialization data to the  spreadsheet  file.   The
  2053.         initialization  identifies  the worksheet file as  a  version  1a
  2054.         file, and includes only the data that 1a would write.  This  does
  2055.         not seem to pose any problem with a ".WK1" extension.  When Lotus
  2056.         2.0  loads   a  ".WK1" file with a 1a signature,  no  errors  are
  2057.         generated, so I assume no extension to file type check is done by
  2058.         Lotus 2.0 - 2.2.
  2059.  
  2060.         If  there  is already an open worksheet file, any  calls  to  the
  2061.         lFileOpen  routine will fail with an errCode of -1  being  passed
  2062.         back.   Use  lClose to close the spreadsheet  file,  after  which
  2063.         another call to lFileOpen can be made to open another spreadsheet
  2064.         file.
  2065.  
  2066.         EXAMPLE:       CALL lFileOpen("D:\LOTUS\TESTFILE.WK1")
  2067.                        will override the default "WKS" extension, and
  2068.                        write the file to drive D, in the sub directory
  2069.                        named LOTUS.
  2070.  
  2071.         ERRORS:   Most (?) will be returned in the errCode% variable.
  2072.  
  2073.  
  2074.  
  2075.                                         32
  2076.  
  2077.                                                        123-Write ver 2.0
  2078.                                     Copyright (c) 1990, Thomas J. Vought
  2079.  
  2080.         NAME:           lGetLoc
  2081.         COMPATIBILITY:  All releases.
  2082.         CELL POINTER:   Unchanged.
  2083.  
  2084.         SYNTAX:   lGetLoc(whatCol%, whatRow%)
  2085.  
  2086.                   whatCol%       will be returned equal to the next
  2087.                                  column number that is to be written.
  2088.  
  2089.                   whatRow%       will be returned equal to the next
  2090.                                  row number to be written.
  2091.  
  2092.  
  2093.         Not  a  lot  to say about this one, returns the  row  and  column
  2094.         numbers of the next cell to be written.   Just remember that  the
  2095.         column  and row coordinates are always 0 based, column A = 0  and
  2096.         row 1 = 0.  See also the lSetLoc routine which allows you to  set
  2097.         the row and column for the next write.
  2098.  
  2099.  
  2100.         EXAMPLE:  CALL lGetLocation(currentCol%, currentRow%)
  2101.                   IF (currentRow% + 1) MOD 20 = 0 THEN CALL pageHeader
  2102.  
  2103.                        If you had a routine called pageHeader that you
  2104.                        wanted to call for each 20 row "screen page" this
  2105.                        would do it.  (I think.)
  2106.  
  2107.         ERRORS:
  2108.              File not open:      Variables returned unchanged, no action.
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.                                         33
  2137.  
  2138.                                                        123-Write ver 2.0
  2139.                                     Copyright (c) 1990, Thomas J. Vought
  2140.  
  2141.         NAME:     lGlobal
  2142.         COMPATIBILITY:  All releases.
  2143.         CELL POINTER:   Unchanged.
  2144.  
  2145.         SYNTAX:   lGlobal(item%, switch%)
  2146.  
  2147.                   item%     is a value from 1 to 5.
  2148.  
  2149.                   switch%   adjusts the specified item.
  2150.  
  2151.  
  2152.            When item%     Worksheet global                  switch%
  2153.                 is:        item effected:                   value:
  2154.  
  2155.                   1    Calculation iterations.      1 through 255     1 *
  2156.  
  2157.                   2    Auto recalculation.          0 = Off (Manual)
  2158.                                              otherwise On (Automatic)   *
  2159.  
  2160.                   3    Calculation order.           0 = natural         *
  2161.                                                     1 = column-wise
  2162.                                                     2 = row-wise
  2163.  
  2164.                   4    Unformatted Printing.        0 = Formatted print *
  2165.                                             otherwise Unformatted print
  2166.  
  2167.                   5    Global worksheet protection   0 = Unprotected    *
  2168.                                                otherwise protection On
  2169.  
  2170.  
  2171.         This  routine will allow you to change any of the default  global
  2172.         settings  of the worksheet.   If the file is not opened via  lFi-
  2173.         leAppend, the defaults for each item are marked with the * aster-
  2174.         isks above.  The qualifier about how the file is opened is  added
  2175.         because  these settings could already be set in the file that  is
  2176.         being  appended to.  To speed processing, the settings above  are
  2177.         not read when lFileAppend is used, however, they can be added  to
  2178.         a  file opened in append mode.  The last global switch read  will
  2179.         take precedence.
  2180.  
  2181.         A  note  is in order regarding protection.   As a  default,  123-
  2182.         Write  will write each cell as a protected cell, but the  protec-
  2183.         tion  won't  be enabled unless it is specifically turned  on.  In
  2184.         Lotus the /Worksheet Global Protection Enable series of  commands
  2185.         will do it, or in 123-Write a call to this routine.  Cell protec-
  2186.         tion  can be disabled  for a series of cells by using  the  lSet-
  2187.         CellForm  routine,  which  will toggle numeric  and  string  cell
  2188.         protection  off and on.  See also lSetDateForm  and  lSetTimeForm
  2189.         which have toggles for cell protection also.
  2190.  
  2191.         ERRORS:
  2192.              File not open:      No action taken.
  2193.              Invalid item%:      No action taken.  (CP 0)
  2194.  
  2195.  
  2196.  
  2197.                                         34
  2198.  
  2199.                                                        123-Write ver 2.0
  2200.                                     Copyright (c) 1990, Thomas J. Vought
  2201.  
  2202.         NAME      lHideCol
  2203.         COMPATIBILITY:  Release 2.0+
  2204.         CELL POINTER:   No change.
  2205.  
  2206.         SYNTAX:   lHideCol(col%, writeFlag%)
  2207.  
  2208.                   col%           is the zero based column number.
  2209.  
  2210.                   writeflag%     indicates that the hidden column record
  2211.                                  should be written to the spreadsheet
  2212.                                  file.
  2213.  
  2214.         lHidecol  can be used to mark any column  in the worksheet  as  a
  2215.         hidden  column.   Multiple columns can be  hidden  with  repeated
  2216.         calls to this routine.  Lotus 1-2-3 uses a single record for  all
  2217.         255 columns in the spreadsheet, and 123-Write maintains an inter-
  2218.         nal record of the columns you mark as hidden.  When this  routine
  2219.         is called with the write flag non-zero, the hidden column  record
  2220.         is written to the file.
  2221.  
  2222.         A check is made of the column number first.  If the column number
  2223.         is  less  than zero, a check is made of the write flag.   If  the
  2224.         write  flag is non zero, the hidden column record is  written  to
  2225.         the file.  This allows you to specify writing the record  without
  2226.         specifying a column to hide (ie: call with -1 and -1).
  2227.  
  2228.         The  123-Write internal record is not reset until a call is  made
  2229.         to  lFileOpen  or lFileAppend.  This means that if your  code  is
  2230.         hiding  columns interactively with the user, you could call  this
  2231.         routine  with  the write flag set each time the user  selected  a
  2232.         column.  The  end result would be that all selected  columns  are
  2233.         hidden, but the disk file would be needlessly bloated.  A  better
  2234.         method in this situation would be to leave the write flag zero as
  2235.         columns are marked, then call this routine with the column varia-
  2236.         ble set to less than zero and the write flag non zero immediately
  2237.         before calling lClose.
  2238.  
  2239.         Because  123-Write doesn't allow nested functions  and  formulas,
  2240.         the ability to hide a column is very handy.  You could place  the
  2241.         needed  comparison  data and constant data into  cells  that  are
  2242.         hidden,  and preserve an uncluttered appearance in the  resulting
  2243.         spreadsheet.
  2244.  
  2245.         ERRORS:
  2246.              No file open:       No action taken.
  2247.              Column <0 or >255:  Write flag checked. If flag is non-zero,
  2248.                                   the record is written.
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.                                         35
  2259.  
  2260.                                                        123-Write ver 2.0
  2261.                                     Copyright (c) 1990, Thomas J. Vought
  2262.  
  2263.         NAME:           lLeft
  2264.         COMPATIBILITY:  All releases.
  2265.         CELL POINTER:   Column is decreased count% times.
  2266.  
  2267.         SYNTAX:   lLeft(count%)
  2268.  
  2269.                   count%    is the number of columns.
  2270.  
  2271.         lLeft  is the equivalent of hitting the left arrow key in  Lotus.
  2272.         The  next  col to be written will be decreased by the  number  of
  2273.         columns  the  routine is called with.  Attempts  to  cursor  left
  2274.         beyond column 0 will leave the cursor in column 0 (A).
  2275.  
  2276.  
  2277.         EXAMPLE:       move% = 5
  2278.                        CALL lLeft(move%)
  2279.                           'The next cell to be written will be 5 to the
  2280.                           'left of the current cell, in the same row.
  2281.  
  2282.         ERRORS:
  2283.              No file open:                 No action taken.
  2284.              current column - count% < 0:  Column set to zero.
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.                                         36
  2320.  
  2321.                                                        123-Write ver 2.0
  2322.                                     Copyright (c) 1990, Thomas J. Vought
  2323.  
  2324.         NAME:           lLineFeed
  2325.         COMPATIBILITY:  All Releases.
  2326.         CELL POINTER:   Col set to zero, Row incremented by 1.
  2327.  
  2328.         SYNTAX:   lLineFeed
  2329.  
  2330.         When called, resets the internal column pointer to 0, (Column  A)
  2331.         and increases the row pointer by one.  The next cell to be  writ-
  2332.         ten  will  one row lower in column A.  If an attempt is  made  to
  2333.         write past row 8195, the cell pointer will stay in row 8195.
  2334.  
  2335.  
  2336.         See lColFunction for an example of using lLineFeed.
  2337.  
  2338.         ERRORS:
  2339.              No file open:       No action taken.
  2340.              Current row=8191:   Row remains at 8191. Column set to zero.
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.                                         37
  2381.  
  2382.                                                        123-Write ver 2.0
  2383.                                     Copyright (c) 1990, Thomas J. Vought
  2384.  
  2385.         NAME:           lLink
  2386.         COMPATIBILITY:  Release 2.2+
  2387.         CELL POINTER:   Column increamented by one.
  2388.  
  2389.         SYNTAX:   lLink(fileSpecRange$)
  2390.  
  2391.  
  2392.                   fileSpecRange$      is a properly formatted linked cell
  2393.                                       reference.  It must be in the:
  2394.                                            <<fileSpec>>RangeName
  2395.                                       format.
  2396.  
  2397.  
  2398.         lLink is intended to be used only with spreadsheet files that are
  2399.         targeted  to be used by Lotus 1-2-3 Release 2.2 or 3.0.   Spread-
  2400.         sheet linking was not available in earlier releases.
  2401.  
  2402.         To  keep the assembly language code as small and tight as  possi-
  2403.         ble,  I did not add strong type checking to the string you  pass.
  2404.         Therefore,  the string passed to this routine must be exactly  as
  2405.         it would be typed into a cell in 1-2-3.  Two left angle brackets,
  2406.         the  full drive and path (if needed) the spreadsheet  file  name,
  2407.         two right angle brackets and the cell (not recommended) or  range
  2408.         name to link in.
  2409.  
  2410.         Care should be taken to use a range name in the spreadsheet  that
  2411.         contains  the data to be read into the current worksheet.   If  a
  2412.         cell reference is made to a linked worksheet, and that  worksheet
  2413.         is  modified (a row inserted for example) the data read into  the
  2414.         current  worksheet will be erroneous.  By using range  names,  no
  2415.         matter  how the referenced worksheet is changed, the result  will
  2416.         be  correct.  I know, the range could be deleted from the  refer-
  2417.         enced worksheet, but that's life.
  2418.  
  2419.         The range name to reference should be early in the file if it's a
  2420.         file  written by 123-Write.  If the range is buried in the  file,
  2421.         intstead  of  being written right after the lFileOpen  call,  the
  2422.         link may fail.   Single cell ranges seem to work more reliably.
  2423.  
  2424.         Remember that 123-Write does not calculate any formulas or  func-
  2425.         tions.   When 123-Write writes a cell to a spreadsheet  file,  if
  2426.         it's a formula, calculation or function, the result is written as
  2427.         zero.  Lotus calculates all formulas and functions when it  reads
  2428.         in  the worksheet, so I elected to take the quick way  out.   Why
  2429.         calculate  something  twice?  Especially something  like  a  four
  2430.         quadrant  arctangent!   Therefore if you want to link in  a  cell
  2431.         from a spreadsheet that was written by 123-Write, the result  may
  2432.         be a zero.  The best way around this is to have a test cell in an
  2433.         out  of  the way place, that does a comparison for zero  on  some
  2434.         part  of the linked spreadsheet.  See the next page for an  exam-
  2435.         ple.
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.                                         38
  2442.  
  2443.                                                        123-Write ver 2.0
  2444.                                     Copyright (c) 1990, Thomas J. Vought
  2445.  
  2446.         lLink (continued)
  2447.  
  2448.         For example if you use the Lotus @TRUE function in a hidden  cell
  2449.         of  a  reference sheet written by 123-Write, and name  that  cell
  2450.         TRUE_RANGE,  then  in the current worksheet include a  cell  that
  2451.         links to it, let's say in cell AA1, like:
  2452.  
  2453.         AA1:      <<D:\123\123WRITE.WK1>>TRUE_RANGE
  2454.  
  2455.         Then in AA2, place the link to the data you need for the  current
  2456.         worksheet.   Let's  assume it's in 123WRITE.WK1 in a  cell  range
  2457.         named "Result"
  2458.  
  2459.  
  2460.         AA2:     <<D:\123\123WRITE.WK1>>RESULT
  2461.  
  2462.         Then  you could place the function  @NA (the value NA, in  Lotus-
  2463.         Speak) in cell AA3:
  2464.  
  2465.         AA3:      @NA
  2466.  
  2467.         So now we have everything pretty well set.  Now, the value of the
  2468.         cell:  RESULT in: 123WRITE.WK1 is needed in the "main"  worksheet
  2469.         at  cell  C3.  Using the lCellFunction routine to  write  an  @IF
  2470.         formula, you could write:
  2471.  
  2472.         C3:       @IF(AA1,AA2,AA3)
  2473.  
  2474.         The  result of all this is, is a flag to tell you if  the  target
  2475.         worksheet file has been loaded into and saved from Lotus.
  2476.  
  2477.         If  123-Write  had written 123WRITE.WK1 then the  result  of  the
  2478.         @TRUE  function  in  TRUE_RANGE would be zero,  and  the  current
  2479.         worksheet would compare that zero via cell AA1 and use the  value
  2480.         NA in cell C3.  If Lotus had loaded the 123WRITE.WK1 file, and it
  2481.         had  been saved, @TRUE in TRUE_RANGE would be 1, cell AA1 in  the
  2482.         current  worksheet would be 1, and cell C3 would equal the  value
  2483.         read  into  AA2,  which is the calculated result  in  the  RESULT
  2484.         range.
  2485.  
  2486.         Clear as mud right?  It sounds worse than it is, in reality it is
  2487.         really simple to implement from 123-Write or Lotus.
  2488.  
  2489.         ERRORS:
  2490.              File not open:      No action taken.
  2491.              Null String:        No action taken.  (CP 0)
  2492.              String > 240 bytes: No action taken.  (CP 0)
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.                                         39
  2503.  
  2504.                                                        123-Write ver 2.0
  2505.                                     Copyright (c) 1990, Thomas J. Vought
  2506.  
  2507.         NAME:           lMultiCellMath
  2508.         COMPATIBILITY:  All Releases.
  2509.         CELL POINTER:   Column increamented by one.
  2510.  
  2511.         SYNTAX:   lMultiCellMath(dSeg%, dOfs%)
  2512.  
  2513.                   dSeg%    is the VARSEG() of a single dimension integer
  2514.                            array with the column and row coordinates and
  2515.                            the operation to be performed.
  2516.  
  2517.                   dOfs%    is the VARPTR() to the array.
  2518.  
  2519.         This routine is going to take some getting used to.  It's purpose
  2520.         is to write calculations to the current cell using multiple  cell
  2521.         references.  (There is a limit to the number of referenced cells,
  2522.         roughly  341(?)  cells but I wouldn't want to try  and  find  the
  2523.         maximum.)
  2524.  
  2525.         The  integers in the array are read and acted upon  sequentially.
  2526.         Each  cell operation requires three elements, the column  number,
  2527.         the  row number and what to do with it, the operation code.   The
  2528.         routine  starts reading from the specified element in the  array,
  2529.         so  be sure to put the first column reference in the element  you
  2530.         use  as an argument to the VARSEG and VARPTR functions.  The  end
  2531.         of  the formula is indicated by an operation code of  zero  after
  2532.         the last cell coordinates.  DO NOT assume that the upper bound of
  2533.         the  array is checked, it is NOT.  If the last operation code  in
  2534.         the  array  is  not a zero, this routine  will  continue  reading
  2535.         forever, if it doesn't happen to hit a zero in the third "set".
  2536.  
  2537.         The operation codes, the third element of each set, are:
  2538.  
  2539.              0.   end of calculation.
  2540.              1.   add next cell.
  2541.              2.   subtract next cell.
  2542.              3.   multiply by the next cell.
  2543.              4.   divide by the next cell.
  2544.  
  2545.         Again,  an example might be the best way to illustrate.  A  work-
  2546.         sheet with 4 columns (0-3, A-D) of data.  We want to take  column
  2547.         A's  (0) value, add column B's (1) value to it, and subtract  the
  2548.         value  in  column D (3), placing the result in column E  (4)  for
  2549.         each row.
  2550.  
  2551.  
  2552.         See the next page for the code example.
  2553.  
  2554.         ERRORS:
  2555.              File not open:                No action.        (CP 0)
  2556.              Actual 3rd integer not (1-5): La La land.       (CP ???)
  2557.              A element, multiple of 3
  2558.                   not in range (0-5):      Terminates function. (CP +)
  2559.  
  2560.  
  2561.  
  2562.  
  2563.                                         40
  2564.  
  2565.                                                        123-Write ver 2.0
  2566.                                     Copyright (c) 1990, Thomas J. Vought
  2567.  
  2568.         LMultiCellMath (continued)  Example 1.
  2569.  
  2570.              DIM Array%(1 TO 9)
  2571.                  .
  2572.              worksheet file is opened etc...
  2573.                  .
  2574.              startRow% = 3           'The operations and columns
  2575.              endRow% = 30            'are constant, so set them:
  2576.              Array%(1) = 0           'Element '1' col number (A)
  2577.              Array%(3) = 1           'Element '3' operation: Add next
  2578.              Array%(4) = 1           'Element '1' col number (B)
  2579.              Array%(6) = 2           'Element '3' operation: Sub next
  2580.              Array%(7) = 3           'Element '1' col number (D)
  2581.              Array%(9) = 0           'Element '3' operation: End calc
  2582.  
  2583.              FOR i% = startRow% TO endRow%
  2584.                   .
  2585.                   .
  2586.                   write the row data,
  2587.                   columns 0 to 3 (A - D)
  2588.                   .
  2589.                   .
  2590.                   Array%(2) = i%           'The row numbers are going
  2591.                   Array%(5) = i%           'to change to reflect the
  2592.                   Array%(8) = i%           'row we're in.
  2593.                   '
  2594.                   'Then write the formula to column E:
  2595.                   '
  2596.                   CALL lMultiCellMath(VARSEG(Array%(1)),VARPTR(Array%(1))
  2597.                   CALL lLineFeed
  2598.              NEXT i%
  2599.  
  2600.         Again  note that BASIC can move data around in memory, and it  is
  2601.         important not to assume that an array's (or structure's)  address
  2602.         in memory will stay the same.  My examples show the VARSEG()  and
  2603.         VARPTR() functions embedded in the calls because I don't like  to
  2604.         take any chances.  Just a chicken at heart I guess.
  2605.  
  2606.         Also  note  that a structure could be used instead of  an  array,
  2607.         just  be sure the "third element = 0" rule is observed.  See  the
  2608.         next page for a coding example that duplicates the above, but  is
  2609.         a little easier to comprehend.
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.                                         41
  2625.  
  2626.                                                        123-Write ver 2.0
  2627.                                     Copyright (c) 1990, Thomas J. Vought
  2628.  
  2629.         LMultiCellMath (continued)  Example 2.
  2630.  
  2631.         TYPE MultiMathStructure
  2632.              col  AS INTEGER
  2633.              row  AS INTEGER
  2634.              opr  AS INTEGER
  2635.         END TYPE
  2636.  
  2637.         DIM multiMath(1 to 3) AS MultiMathStructure
  2638.              .
  2639.          worksheet file is opened etc...
  2640.              .
  2641.         startRow% = 3           'The operations and columns
  2642.         endRow% = 30            'are constant, so set them:
  2643.         multiMath(1).col = 0    'Cell '1' col number (A)
  2644.         multiMath(1).opr = 1    'Cell '1' operation: Add next
  2645.         multiMath(2).col = 1    'Cell '2' col number (B)
  2646.         multiMath(2).opr = 2    'Cell '2' operation: Sub next
  2647.         multiMath(3).col = 3    'Cell '3' col number (D)
  2648.         multiMath(3).opr = 0    'Cell '3' operation: End calc
  2649.  
  2650.         FOR i% = startRow% TO endRow%
  2651.              .
  2652.              .
  2653.              write the row data,
  2654.              columns 0 to 3 (A - D)
  2655.              .
  2656.              .
  2657.             multiMath(1).row = i%     'The row numbers are going
  2658.             multiMath(2).row = i%     'to change to reflect the
  2659.             multiMath(3).row = i%     'row we're in.
  2660.              '
  2661.              'Then write the formula to column E:
  2662.              '
  2663.             CALL lMultiCellMath(VARSEG(multiMath(1)),VARPTR(multiMath(1))
  2664.             CALL lLineFeed
  2665.         NEXT i%
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.                                         42
  2686.  
  2687.                                                        123-Write ver 2.0
  2688.                                     Copyright (c) 1990, Thomas J. Vought
  2689.  
  2690.         NAME:           lPrintBorders
  2691.         COMPATIBILITY:  All Releases.
  2692.         CELL POINTER:   No change.
  2693.  
  2694.         SYNTAX:
  2695.  
  2696.         lPrintBorders(rulc%,rulr%,rlrc%,rlrr%,culc%,culr%,clrc%,clrr%)
  2697.  
  2698.  
  2699.                   rulc%     is the Border Row upper left column
  2700.                   rulr%     is the Border Row upper left row
  2701.                   rlrc%     is the Border Row lower right column
  2702.                   rlrr%     is the Border Row lower right row
  2703.  
  2704.                   culc%     is the Border Column upper left column
  2705.                   culr%     is the Border Column upper left row
  2706.                   clrc%     is the Border Column lower right column
  2707.                   clrr%     is the Border Column lower right row
  2708.  
  2709.         Yes,  eight  parameters for one call.  Lotus 1-2-3  requires  all
  2710.         eight  in  one record, consequently it has to be written  to  the
  2711.         file as one record.
  2712.  
  2713.         Lotus  uses a unique method to indicate an undefined range  which
  2714.         is also used internally by 123-Write.  It would be cumbersome  to
  2715.         have to call this routine with the proper values, so I wrote a
  2716.         test into the code for this function:
  2717.  
  2718.         If  the sum of all the range values (either the column  range  or
  2719.         the row range) are less than zero, the range is not defined.
  2720.         When  you  define a column or row print border in  Lotus,  it  is
  2721.         acceptable to define one cell as the 'column' or one cell as  the
  2722.         'row',  you  can  do that in 123-Write also.   For  instance,  to
  2723.         define column A as the column border and row 1 as the row border,
  2724.         just call lPrintBorders with eight zeros.
  2725.  
  2726.         EXAMPLES:
  2727.                  'Set only border rows of rows 1 through 4:
  2728.                  CALL lPrintBorders (0, 0, 0, 3, -1, 0, 0, 0)
  2729.                  'The column range above is less than 0: not defined.
  2730.  
  2731.                  'Set only border columns of columns A and B:
  2732.                  CALL lPrintBorders (-1, -1, -1, -1, 0, 0, 1, 0)
  2733.                  'The row range above is less than 0: not defined.
  2734.  
  2735.                  'Set both the above as the borders:
  2736.                  CALL lPrintBorders (0, 0, 0, 3, 0, 0, 1, 0)
  2737.                  'the border rows are 1 through 4 and columns are A & B.
  2738.  
  2739.         ERRORS:
  2740.              File not open:      No action taken.
  2741.              Illegal column or
  2742.              Illegal row number: Written to the file.  No check is made.
  2743.  
  2744.  
  2745.  
  2746.                                         43
  2747.  
  2748.                                                        123-Write ver 2.0
  2749.                                     Copyright (c) 1990, Thomas J. Vought
  2750.  
  2751.         NAME:           lPrintMargins
  2752.         COMPATIBILITY:  All Releases.
  2753.         CELL POINTER:   No change.
  2754.  
  2755.         SYNTAX:   lPrintMargins(lm%, rm%, tm%, bm%, pageLen%)
  2756.  
  2757.                   lm%         is the left margin
  2758.                   rm%         is the right margin
  2759.                   tm%         is the top margin
  2760.                   bm%         is the bottom margin
  2761.                   pageLen%    is the page length
  2762.  
  2763.         lPrintMargins  sets the printer margins used by Lotus for  subse-
  2764.         quent printing.  When 123-Write opens (rather than appends to)  a
  2765.         worksheet file, these variables are set to the default values of:
  2766.                   Left   =  4
  2767.                   Right  = 76
  2768.                   Top    =  2
  2769.                   Bottom =  2
  2770.                   Page   = 66
  2771.  
  2772.         If needed, the default, or previously set (if the file was opened
  2773.         for append) margins can be changed by calling this routine.  NOTE
  2774.         that all the variables will be written to the worksheet file.  If
  2775.         you  want to change just the right margin for example,  you  must
  2776.         still  supply all the other parameters.  Lotus requires all  mar-
  2777.         gins be set in one record.
  2778.  
  2779.         EXAMPLE:
  2780.  
  2781.              lm% = 10
  2782.              rm% = 130
  2783.              tm% = 2
  2784.              bm% = 2
  2785.              page% = 66
  2786.              CALL lPrintMargins(lm%, rm%, tm%, bm%, page%)
  2787.  
  2788.              'In effect just changes the left and right print margins.
  2789.  
  2790.         ERRORS:
  2791.              No file open:       No action taken.
  2792.              Illegal column or
  2793.              Illegal row number: Written to the file.  No check is made.
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.                                         44
  2808.  
  2809.                                                        123-Write ver 2.0
  2810.                                     Copyright (c) 1990, Thomas J. Vought
  2811.  
  2812.         NAME:           lPrintRange
  2813.         COMPATIBILITY:  All Releases.
  2814.         CELL POINTER:   No change.
  2815.  
  2816.         SYNTAX:   lPrintRange (ulc%, ulr%, lrc%, lrr%)
  2817.  
  2818.                   ulc%           is the upper left column of the range.
  2819.                   ulr%           is the upper left row of the range.
  2820.                   lrc%           is the lower right column of the range.
  2821.                   lrr%           is the lower right row of the range.
  2822.  
  2823.  
  2824.         lPrintRange  sets up the default print range for  the  worksheet.
  2825.         This allows you to predetermine the range, and then you can  just
  2826.         add  a  macro to print it when Alt-P is pressed.  Saves  time  in
  2827.         macro  writing  if the range is preset, by  eliminating  all  the
  2828.         range input needed to set up the print range.  The example
  2829.         below  shows how it can be done.  If you use the lGetLoc  routine
  2830.         and  save  the bottom-most row and right-most col  to  variables,
  2831.         then set the print range, it allows you to always define the full
  2832.         range  of cells for printing regardless of the size of the  work-
  2833.         sheet.
  2834.  
  2835.  
  2836.         EXAMPLE:
  2837.  
  2838.                   'Let's assume all the data has been written
  2839.                   'to the spreadsheet, and that the upper left
  2840.                   'corner of the print range is 0, 0 (A1) and the
  2841.                   'lower right corner is in the variables lrc% and
  2842.                   'lrr%
  2843.  
  2844.                   CALL lPrintRange (0, 0, lrc%, lrr%)
  2845.                   column% = lCol ("Z")
  2846.                   CALL lSetLoc (column%, 0)              'Macro in Z1
  2847.                   CALL lRange("\P", column%, 0, column%, 0)  'Name it
  2848.                   CALL lWriteStr("/PPAGQ", errCode%)    '1 cell macro
  2849.  
  2850.                   'The Alt-P macro is just a PRINT, PRINTER, ALIGN,
  2851.                   '   GO, QUIT sequence.
  2852.  
  2853.         ERRORS:
  2854.              No file open:       No action taken.
  2855.              Illegal column or
  2856.              Illegal row number: Written to the file.  No check is made.
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.                                         45
  2869.  
  2870.                                                        123-Write ver 2.0
  2871.                                     Copyright (c) 1990, Thomas J. Vought
  2872.  
  2873.         NAME:           lPrintSetup
  2874.         COMPATIBILITY:  All Releases.
  2875.         CELL POINTER:   No change.
  2876.  
  2877.         SYNTAX:   lPrintSetup (setup$)
  2878.  
  2879.                   setup$    is the Lotus style print control string.
  2880.  
  2881.         Assigns a printer setup string to the worksheet.  The string  you
  2882.         pass  to this routine is used exactly as received.  An  exception
  2883.         is  that only the first 40 characters are used if the  string  is
  2884.         over  40  characters long.  Remember to use  the  back-slash  (\)
  2885.         character  to start and three digit ASCII numbers to  define  the
  2886.         setup string.
  2887.  
  2888.  
  2889.         EXAMPLE:
  2890.  
  2891.                   'Setting my printer into near letter quality mode
  2892.                   'requires an ESC-W-1 string.  ASCII 27, 88, 49
  2893.  
  2894.                   setup$ = "\027\088\049"
  2895.                   CALL lPrintSetup (setup$)
  2896.  
  2897.         ERRORS:
  2898.              No file open:       No action taken.
  2899.              Null String:        No action taken.       (CP 0)
  2900.              String > 39 bytes.  Truncated to 39 bytes. (CP +)
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.  
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.                                         46
  2930.  
  2931.                                                        123-Write ver 2.0
  2932.                                     Copyright (c) 1990, Thomas J. Vought
  2933.  
  2934.         NAME:           lPrintTitle
  2935.         COMPATIBILITY:  All Releases.
  2936.         CELL POINTER:   No change.
  2937.  
  2938.         SYNTAX:   lPrintTitle (title$, header%)
  2939.  
  2940.                   title$    is the string to assign to the print output.
  2941.                   header%   is a flag to indicate a title (non-zero)
  2942.                                               or a footer (zero)
  2943.  
  2944.  
  2945.         When  called, sets up either the print title, if header% is  non-
  2946.         zero, or the print footer if header% is zero.  The string  passed
  2947.         to this routine is truncated if over 240 characters.
  2948.  
  2949.  
  2950.         The  special  formatting  characters should be  included  in  the
  2951.         string  passed to this routine.  The | character can be  used  to
  2952.         break  the line into three separate text blocks, each aligned  on
  2953.         the  page differently.  The @ character will be replaced  by  the
  2954.         current system time when the print command is issued.  The  third
  2955.         format  character is # which indicates page numbering.  The  page
  2956.         number is only reset to 1 when the /Print command is invoked.
  2957.  
  2958.  
  2959.         EXAMPLE:
  2960.  
  2961.                   header$ = "|Income Statement"
  2962.                   footer$ = "|2nd Quarter 1989"
  2963.                   CALL lPrintTitle (header$, -1)
  2964.                   CALL lPrintTitle (footer$, 0)
  2965.  
  2966.                   'Both the header and footer above will be centered,
  2967.                   'There is no 'Left' block.
  2968.  
  2969.                   header$="Income Statement||Page #"
  2970.  
  2971.                   'Will result in a left aligned title, with the page
  2972.                   'number right aligned for instance.
  2973.  
  2974.         ERRORS:
  2975.              No file open:       No action taken.
  2976.              Null String:        No action taken.       (CP 0)
  2977.              String > 240 bytes. Truncated to 240 bytes. (CP +)
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.                                         47
  2991.  
  2992.                                                        123-Write ver 2.0
  2993.                                     Copyright (c) 1990, Thomas J. Vought
  2994.  
  2995.         NAME:           lRange
  2996.         COMPATIBILITY:  All Releases.
  2997.         CELL POINTER:   No change.
  2998.  
  2999.         SYNTAX:   lRange(rangeName$, ulc%, ulr%, lrc%, lrr%)
  3000.  
  3001.                   rangeName$     is the name to assign.
  3002.                   ulc%           is the upper left column of the range.
  3003.                   ulr%           is the upper left row of the range.
  3004.                   lrc%           is the lower right column of the range.
  3005.                   lrr%           is the lower right row of the range.
  3006.  
  3007.         lRange  assigns  a name of up to 15 characters to  the  specified
  3008.         range.   Any  characters  over 15 are ignored.   The  range  name
  3009.         supplied  is  NOT parsed to replace any invalid  characters.  The
  3010.         name passed to the routine remains unaltered.
  3011.  
  3012.         Range  names  are a great time saver in Lotus.   When  writing  a
  3013.         spreadsheet  via 123-Write, you can't be sure that a  user  won't
  3014.         move data around after you've written the file.  This is a  prob-
  3015.         lem  when  writing macros especially, if you "hard code"  a  cell
  3016.         reference in a text string, it will always refer to that cell, no
  3017.         matter where the actual data you want to work with is.  By  using
  3018.         macros  that have range names in them exclusively, the  end  user
  3019.         can  move  everything  around, yet your macros  will  still  work
  3020.         correctly.
  3021.  
  3022.         As  mentioned  at the start of this document,  if  possible,  the
  3023.         range names should be written early in the file.
  3024.  
  3025.         EXAMPLE:
  3026.  
  3027.            CALL lRange("Income", lCol("B"), 0, lCol("D"), 19)
  3028.  
  3029.             Assigns the name INCOME to the range from B1 through D20.
  3030.  
  3031.         ERRORS:
  3032.              No file open:       No action taken.
  3033.              Null String:        No action taken.       (CP 0)
  3034.              String > 15 bytes.  Truncated to 15 bytes. (CP +)
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.  
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.                                         48
  3052.  
  3053.                                                        123-Write ver 2.0
  3054.                                     Copyright (c) 1990, Thomas J. Vought
  3055.  
  3056.         NAME:           lRight
  3057.         COMPATIBILITY:  All Releases.
  3058.         CELL POINTER:   Column incremented by count%. No change to row.
  3059.  
  3060.         SYNTAX:   lRight(count%)
  3061.  
  3062.                   count%    is the number of columns.
  3063.  
  3064.         lRight is the equivalent of hitting the right arrow key in Lotus.
  3065.         The next column to be written will be increased by the number  of
  3066.         columns the routine is called with.  The maximum column number is
  3067.         255  (IV).   Attempts to 'cursor' right beyond  column  255  will
  3068.         leave the cursor in column 255.
  3069.  
  3070.  
  3071.         EXAMPLE:       move% = 5
  3072.                        CALL lRight(move%)
  3073.                           'The next cell to be written will be 5 columns
  3074.                           'to the right of the current column, in the
  3075.                           'same row.
  3076.  
  3077.  
  3078.         ERRORS:
  3079.              File not open:                     No action taken.
  3080.              Current column + count > 255:      Column set to 255 (IV).
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.                                         49
  3113.  
  3114.                                                        123-Write ver 2.0
  3115.                                     Copyright (c) 1990, Thomas J. Vought
  3116.  
  3117.         NAME:           lRowFunction
  3118.         COMPATIBILITY:  All releases, except @COLS, ver 2.0+
  3119.         CELL POINTER:   Increased one column.
  3120.  
  3121.         SYNTAX:   lRowFunction(startCol%, endCol%, oper%)
  3122.  
  3123.                   startCol%      represents the first col to operate on.
  3124.                   endCol%        represents the last col to operate on.
  3125.                   oper%          is set to one of the following:
  3126.  
  3127.                             1.   @SUM the sum of the cells.
  3128.                             2.   @AVG the average of the cells.
  3129.                             3.   @COUNT the count of cells with
  3130.                                         valid data.
  3131.                             4.   @MIN the lowest value in the range.
  3132.                             5.   @MAX the highest value in the range.
  3133.                             6.   @STD the stnd deviation of the range.
  3134.                             7.   @VAR the variance of the range.
  3135.                             8.   @COLS the count of the cols inclusive.
  3136.  
  3137.         lRowFunction is a quick method of writing common row functions to
  3138.         a  cell,  or a series of cells.  The routine assumes the  row  to
  3139.         operate  on is the current row, so all that's needed in the  call
  3140.         is the first column to include and the last column to include.
  3141.  
  3142.         To  illustrate, lets say you're writing a spreadsheet  where  you
  3143.         want  the sum (@SUM) of the first four columns (A-D) in column  E
  3144.         of each row:
  3145.  
  3146.                   FOR i% = 1 TO LOF(dataFile%) \ LEN(dataRecord%)
  3147.                        .
  3148.                        ...writing a row loop...
  3149.                        .
  3150.                        CALL lRowFunction(0, 3, 1)     '@SUM the row.
  3151.                        CALL lLineFeed         'Get set for next row.
  3152.                   NEXT i%
  3153.  
  3154.         ERRORS:
  3155.              File not open:      No action taken.
  3156.              oper% <1 or >8:     @ERR written to current cell. (CP +)
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.                                         50
  3174.  
  3175.                                                        123-Write ver 2.0
  3176.                                     Copyright (c) 1990, Thomas J. Vought
  3177.  
  3178.         NAME:           lSetCellForm
  3179.         COMPATIBILITY:  All releases, except as noted below.
  3180.         CELL POINTER:   No change.
  3181.  
  3182.         SYNTAX:   lSetCellForm(formatCode%, decimals%)
  3183.  
  3184.                   formatCode%    Indicates the desired format for numeric
  3185.                                  and string cells written after this
  3186.                                  routine is called.
  3187.  
  3188.                   decimals%      Usually the number of decimal places you
  3189.                                  want displayed in subsequent cells.
  3190.  
  3191.         FormatCode%                                            decimals%
  3192.         -----------                                            ---------
  3193.              1              Fixed number of decimal places.    1 thru 15
  3194.              2              Scientific notation.               1 thru 15
  3195.              3              Currency format.                   1 thru 15
  3196.              4              Percent format.                    1 thru 15
  3197.              5              Comma format.                      1 thru 15
  3198.              6              Special format                    (see below)
  3199.              7              Set cell protection.            0=Off else On
  3200.  
  3201.  
  3202.         Sets  the  default  cell display for  subsequent  numeric  cells.
  3203.         Default string alignment can be changed, see lSetStrForm.
  3204.  
  3205.         For  the Fixed, Scientific, Currency, Percent and comma  formats,
  3206.         the  decimals% parameter represents the number of decimal  places
  3207.         to display, from 0 through 15.
  3208.  
  3209.         For  the protection option, the decimals% is used as a flag.   If
  3210.         it  is  zero, cell protection will be turned off.   Any  non-zero
  3211.         value  will  turn  on cell protection.  Note that  if  you  write
  3212.         unprotected cells, 1-2-3 will highlight them when the spreadsheet
  3213.         is loaded.
  3214.  
  3215.         For the Special option, number 6, the following formats are  set,
  3216.         based upon the value of decimals%:
  3217.  
  3218.         value    Result:                 value    result:
  3219.         -----    -------                 -----    -------
  3220.            0     + / - format.              9     Date, Int'l 1  (2.0+)
  3221.            1     General                   10     Date, Int'l 2  (2.0+)
  3222.            2     Date 1: dd-mmm-yyyy       11     Time, Int'l 1  (2.0+)
  3223.            3     Date 2: dd-mmm            12     Time, Int'l 2  (2.0+)
  3224.            4     Date 3: mmm-yy        13--15     Default (Cell takes
  3225.            5     Text                             whatever format is set
  3226.            6     Hidden  (2.0+)                   by /Worksheet Global
  3227.            7     Time 1: hh:mm:ss AM/PM (2.0+)    Format command.
  3228.            8     Time 2: hh:mm AM/PM    (2.0+)
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.                                         51
  3235.  
  3236.                                                        123-Write ver 2.0
  3237.                                     Copyright (c) 1990, Thomas J. Vought
  3238.  
  3239.         lSetCellForm (continued)
  3240.  
  3241.         Individual cells, though marked as protected cells aren't  "write
  3242.         protected"  unless  worksheet  protection  is  enabled.   Default
  3243.         worksheet protection is disabled, so a call to lGlobal is  needed
  3244.         to "write protect" protected cells.
  3245.  
  3246.         When  a worksheet file is first opened, if no other formats  have
  3247.         been  set  (from a previously completed file,  for  example)  the
  3248.         format  string  is set to: Protected, Special,  Default  by  123-
  3249.         Write.
  3250.  
  3251.         EXAMPLES:      CALL lSetCellForm(1,3)   'result:  ####.###
  3252.                        CALL lSetCellForm(4,2)   'result:  #,###.##
  3253.                        CALL lSetCellForm(3,2)   'result: $#,###.##
  3254.  
  3255.                        CALL lSetCellForm(7,-1)
  3256.                            'results in cell protection being turned on.
  3257.  
  3258.         ERRORS:
  3259.              File not open:           Cell format set.         (CP 0)
  3260.              formatCode% <1 or >7:    No action taken. Last (or default)
  3261.                                         is still in effect.    (CP 0)
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.                                         52
  3296.  
  3297.                                                        123-Write ver 2.0
  3298.                                     Copyright (c) 1990, Thomas J. Vought
  3299.  
  3300.         NAME:           lSetCol
  3301.         COMPATIBILITY:  All releases.
  3302.         CELL POINTER:   No change.
  3303.  
  3304.         SYNTAX:   lSetCol(col%, colWidth%)
  3305.  
  3306.                   col%      is the column number to set,
  3307.                   colWidth% is the width for the column.
  3308.  
  3309.         Sets  the column width for an individual column. See lSetCols  if
  3310.         you want to set a range of columns at one time.
  3311.  
  3312.         The Lotus default column width is 9 characters wide.  You can set
  3313.         the width of any column to another value by calling this routine.
  3314.         The valid widths are 1 to 240 maximum.
  3315.  
  3316.  
  3317.         EXAMPLE:       CALL lSetCol(3, 20)
  3318.                        CALL lSetCol(lCol("D"),20)
  3319.  
  3320.                        both set column D's width to 20 characters.
  3321.  
  3322.  
  3323.         ERRORS:
  3324.              File not open:           No action taken.
  3325.              column%<0 or >255:       Set to low byte value. (CP 0)
  3326.              colWidth% <0 or >240:    Set to low byte value. (CP 0)
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.                                         53
  3357.  
  3358.                                                        123-Write ver 2.0
  3359.                                     Copyright (c) 1990, Thomas J. Vought
  3360.  
  3361.         NAME:           lSetCols
  3362.         COMPATIBILITY:  All releases.
  3363.         CELL POINTER:   No change.
  3364.  
  3365.         SYNTAX:   lSetCols(colWidths%())
  3366.  
  3367.                   colWidths%()  is a single dimension integer array, the
  3368.                                 element number indicates the column, the
  3369.                                 content of the element indicates the
  3370.                                 width for the column.
  3371.  
  3372.  
  3373.         lSetCols is for setting multiple columns to different widths with
  3374.         one call.  Whether you use this routine or set the column  widths
  3375.         individually  with lSetCol is your call.  lSetCols is written  in
  3376.         BASIC, the source file being LSETCOLS.BAS.  lSetCols calls  lSet-
  3377.         Col  using the LBOUND and UBOUND  of the passed array as  a  loop
  3378.         control, so the columns have to be within one range.
  3379.  
  3380.         The integer array holds the width for each column.  The  position
  3381.         in  the  array determines the column.  If you want  to  use  this
  3382.         routine  to set column zero, there must be a zero element in  the
  3383.         array passed.  No OPTION BASE 1 statement in this case, or use  a
  3384.         DIM array%(0 to whatever%) statement to over-ride the OPTION BASE
  3385.         statement.
  3386.  
  3387.         With QuickBASIC 4.0+ and BASCOM 6.0+ it is possible to set  lower
  3388.         array  bounds  of  other then 0 or 1, which is  handy  with  this
  3389.         routine.   If you want to set columns 9 through 17  for  example,
  3390.         you can:
  3391.  
  3392.              REDIM temp%(9 TO 17)
  3393.              ...set elements 9 through 17 to desired widths...
  3394.              CALL lSetCols(temp%())
  3395.  
  3396.         EXAMPLE:       See above.
  3397.  
  3398.         ERRORS:
  3399.  
  3400.         A lower bound less then 0 will result in NO column width data  at
  3401.         all being written.   (CP 0)
  3402.  
  3403.         If  the  width for a column (element) is less than 1  or  greater
  3404.         than  240 that column is skipped, and it's width is left  at  the
  3405.         default (or other) setting of 9.   (CP 0)
  3406.  
  3407.         File not open:      No action.
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.                                         54
  3418.  
  3419.                                                        123-Write ver 2.0
  3420.                                     Copyright (c) 1990, Thomas J. Vought
  3421.  
  3422.         NAME:           lSetDateForm
  3423.         COMPATIBILITY:  See below.
  3424.         CELL POINTER:   No change.
  3425.  
  3426.         SYNTAX:   lSetDateForm (format%, protect%)
  3427.  
  3428.                   format%        is the desired format number:
  3429.                                  1    dd-mmm-yy       16-Feb-53
  3430.                                  2    dd-mmm          16-Feb
  3431.                                  3    mmm-yy          Feb-53
  3432.         (1-2-3 ver 2.0+ only)    4    mm-dd-yy        02-16-53
  3433.         (1-2-3 ver 2.0+ only)    5    mm-dd           02-16
  3434.  
  3435.                   protect%       is a flag to turn date cell protection
  3436.                                  on (non-zero) or off (zero).
  3437.  
  3438.         Setting the date format is optional, it will default to format 1,
  3439.         the  dd-mmm-yy  arrangement  when the worksheet  is  opened  with
  3440.         lFileOpen.  The date format you set here will be used with subse-
  3441.         quent calls to the lDate and lToday routines, numeric and  string
  3442.         cells are left unchanged.
  3443.  
  3444.         Note  that  this  is a change from version 1.0,  where  the  date
  3445.         format  on calls to lDate was always format 1.  All five  formats
  3446.         are  available  in  Lotus 1-2-3 version 2.0  and  greater.   Only
  3447.         formats 1, 2 and 3 are recognized by version 1a of Lotus.
  3448.  
  3449.         A  date format can also  be specified by calling lSetCellForm  as
  3450.         in  version  1.0.   However, lSetForm causes  all  numeric  cells
  3451.         written  after  it is called to be displayed with  the  specified
  3452.         format.
  3453.  
  3454.         This  routine allows you to cut your code down by setting both  a
  3455.         date format and a standard cell format and not being forced  into
  3456.         the default dd-mmm-yy setting.
  3457.  
  3458.         EXAMPLE:
  3459.              'Assume you're reading and writing 10 field records where
  3460.              'the 5th and 7th fields are dates (all others numeric):
  3461.              CALL lSetDateForm(4,1)    'Lotus D4, protected cell
  3462.              FOR i = 1 TO 10
  3463.                INPUT #inputFile, rec$
  3464.                IF i = 5 OR i = 7 THEN
  3465.                  CALL lDate(rec$)
  3466.                ELSE
  3467.                  a# = VAL(rec$)
  3468.                  CALL lWriteNum(a#)
  3469.                END IF
  3470.              NEXT
  3471.  
  3472.         ERRORS:
  3473.              File not open:      Date format selection is set.  (CP 0)
  3474.              format%<1 or >5:    No action taken.  Last (or default)
  3475.                                      remains in effect.         (CP 0)
  3476.  
  3477.  
  3478.                                         55
  3479.  
  3480.                                                        123-Write ver 2.0
  3481.                                     Copyright (c) 1990, Thomas J. Vought
  3482.  
  3483.         NAME:           lSetLoc
  3484.         COMPATIBILITY:  All releases.
  3485.         CELL POINTER:   Set to parameters.
  3486.  
  3487.         SYNTAX:   lSetLoc(newCol%, newRow%)
  3488.  
  3489.  
  3490.                   newCol%   is the next column you want written,
  3491.  
  3492.                   newRow%   is the next row to write.
  3493.  
  3494.         Use  lSetLoc to position the internal column and row pointers  to
  3495.         any cell (within 255 columns and 2048 or 8192 rows) that you want
  3496.         to write to next.  Column and row ranges are checked, use a maxi-
  3497.         mum row of 2047 for 1-2-3 release 1a, 8191 for later versions.
  3498.  
  3499.         Only thing to mention (again?) is that the column and row coordi-
  3500.         nates  are 0 based, but at least with the lCol function,  we  can
  3501.         get a little help:
  3502.  
  3503.  
  3504.         Example:
  3505.  
  3506.                  CALL lSetLoc(lCol("C"), 6)
  3507.  
  3508.          Will result in the cell pointer being set to write to 'C7' next.
  3509.  
  3510.         ERRORS:
  3511.              File not open:      No action taken.
  3512.              Col<0 or >255:      No action taken.   (CP 0)
  3513.              Row<0 or >8191:     No action taken.   (CP 0)
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.                                         56
  3540.  
  3541.                                                        123-Write ver 2.0
  3542.                                     Copyright (c) 1990, Thomas J. Vought
  3543.  
  3544.         NAME:           lSetStrForm
  3545.         COMPATIBILITY:  All releases except number 5, 2.0+ only.
  3546.         CELL POINTER:   Not changed.
  3547.  
  3548.         SYNTAX:   lSetStrForm(formatCode%)
  3549.  
  3550.                   formatCode% is any one of the following:
  3551.  
  3552.                      1      Left justify text.          '   (Default)
  3553.                      2      Center text in the cell:    ^
  3554.                      3      Right justify text.         "
  3555.                      4      Repeating character:        \
  3556.                      5      The non-print character:    |   (2.0+ only)
  3557.  
  3558.         lSetStrForm  sets the DEFAULT label alignment character  for  all
  3559.         strings written to the file (after this routine is called), if  a
  3560.         label prefix character is not the first character in the string.
  3561.         See the lWriteStr routine for more information on writing  string
  3562.         data.
  3563.  
  3564.         If  the  format code you pass to this routine is not one  of  the
  3565.         five available, the last label prefix character selected, or  the
  3566.         default single quote (') is selected.
  3567.  
  3568.         The  single  quote  (left justify) is the  default  label  prefix
  3569.         character selected when the spreadsheet file is opened via lFile-
  3570.         Open or lFileAppend, unless a previous label prefix character has
  3571.         been defined during the same session.
  3572.  
  3573.         The cell protection can be set to on or off by the lCellForm rou-
  3574.         tine.
  3575.  
  3576.         ERRORS:
  3577.              File not open:      String cell format byte set as above.
  3578.              formatCode<1 or >5: No action, last seeting stays.  (CP 0)
  3579.  
  3580.  
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.                                         57
  3601.  
  3602.                                                        123-Write ver 2.0
  3603.                                     Copyright (c) 1990, Thomas J. Vought
  3604.  
  3605.         NAME:           lSetTimeForm
  3606.         COMPATIBILITY:  Release 2.0+ only.
  3607.         CELL POINTER:   Not changed.
  3608.  
  3609.         SYNTAX:   lSetTimeForm (format%, protect%)
  3610.  
  3611.                   format%        is the desired format number:
  3612.  
  3613.         (am/pm indicator)        1    hh:mm:ss(am/pm)    09:33:45pm
  3614.         (am/pm indicator)        2    hh:mm(am/pm)       09:33pm
  3615.         (24 hour clock)          3    hh:mm:ss           21:33:45
  3616.         (24 hour clock)          4    hh:mm              21:33
  3617.  
  3618.                   protect%       is a flag to toggle cell protection
  3619.                                  on (non-zero) or off (zero).
  3620.  
  3621.         Setting the time format is optional, it will default to format 1,
  3622.         the  hh:mm:ss(am/pm)  arrangement when the worksheet  is  opened.
  3623.         The  time format you set here will be used with subsequent  calls
  3624.         to  lTime.  Note that time formats (and functions) were  not  in-
  3625.         cluded with Lotus until release 2.0.
  3626.  
  3627.         EXAMPLE:
  3628.  
  3629.         An example here would be the same as given with the  lSetDateForm
  3630.         routine,  and  since they're both so similar, I'll refer  you  to
  3631.         that routine for an example.
  3632.  
  3633.  
  3634.         ERRORS:
  3635.            No file open:       Time format set.    (CP 0)
  3636.            format<1 or >4:     No action taken, last setting stays.(CP 0)
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.                                         58
  3662.  
  3663.                                                        123-Write ver 2.0
  3664.                                     Copyright (c) 1990, Thomas J. Vought
  3665.  
  3666.         NAME:           lSortKey
  3667.         COMPATIBILITY:  All releases.
  3668.         CELL POINTER:   Not changed.
  3669.  
  3670.         SYNTAX:   lSortKey (primry%, ulc%, ulr%, lrc%, lrr%, ascnd%)
  3671.  
  3672.                   primry%   indicates whether to set the primary sort key
  3673.                             (non-zero) or the secondary sort key (zero).
  3674.  
  3675.                   ulc%      is the upper left column of the key range.
  3676.                   ulr%      is the upper left row of the key range.
  3677.                   lrc%      is the lower right column of the key range.
  3678.                   lrr%      is the lower right row of the key range.
  3679.  
  3680.                   ascnd%    sets the sort order, ascending (non-zero),
  3681.                             or descending (zero).
  3682.  
  3683.         If  a sort range has been set, the primary sort key and the  sec-
  3684.         ondary sort key can be set via this routine.
  3685.  
  3686.         As  in lPrintRange, this routine can alleviate the need for  long
  3687.         macros.  If the range of data to manipulate is known, it can  all
  3688.         be set up via 123-Write, and a much simpler macro can be written,
  3689.         one that doesn't need to determine boundaries etc.
  3690.  
  3691.         Note that the key ranges must be within the data sort range.
  3692.  
  3693.  
  3694.         EXAMPLE:
  3695.  
  3696.              CALL lSortKey (-1, 0, 0, 0, endRow%, -1)
  3697.  
  3698.              'Sets the primary sort key to cell A1 to cell Ax
  3699.              'where x is a variable row number.
  3700.  
  3701.         ERRORS:
  3702.              File not open:      No action taken     (CP 0)
  3703.              Invalid cells:      Blissfully written to file.  (CP 0)
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.  
  3721.  
  3722.                                         59
  3723.  
  3724.                                                        123-Write ver 2.0
  3725.                                     Copyright (c) 1990, Thomas J. Vought
  3726.  
  3727.         NAME:           lSortRange
  3728.         COMPATIBILITY:  All releases.
  3729.         CELL POINTER:   Not changed.
  3730.  
  3731.         SYNTAX:   lSortRange(ulc%, ulr%, lrc%, lrr%)
  3732.  
  3733.                   ulc%      is the upper left column of the sort range.
  3734.                   ulr%      is the upper left row of the sort range.
  3735.                   lrc%      is the lower right column of the sort range.
  3736.                   lrr%      is the lower right row of the sort range.
  3737.  
  3738.  
  3739.         lSortRange  sets  up the default sort range  for  the  worksheet.
  3740.         This allows you to predetermine the range, and then you can  just
  3741.         add  a  macro to print it when Alt-S is pressed.  Saves  time  in
  3742.         macro  writing  if the range is preset, by  eliminating  all  the
  3743.         range input needed to set up the print range.  The example
  3744.         below  shows how it can be done.  If you use the lGetLoc  routine
  3745.         and save the bottom-most row and right-most column to  variables,
  3746.         then set the sort range, it allows you to always define the  full
  3747.         range  of cells for sorting regardless of the size of  the  work-
  3748.         sheet.
  3749.  
  3750.  
  3751.         EXAMPLE:
  3752.  
  3753.                   'Let's assume all the data has been written
  3754.                   'to the spreadsheet, and that the upper left
  3755.                   'corner of the sort range is 0, 0 (A1) and the
  3756.                   'lower right corner is in the variables lrc% and
  3757.                   'lrr%
  3758.  
  3759.                   CALL lSortRange (0, 0, lrc%, lrr%)
  3760.                   column% = lCol ("AA")
  3761.                   CALL lSetLoc (column%, 0)             'Macro in AA1
  3762.                   CALL lRange("\S", column%, 0, column%, 0)  'Name it
  3763.                   CALL lWriteStr("/DSGQ")               '1 cell macro
  3764.  
  3765.                 'The Alt-S macro is just a DATA, SORT, GO, QUIT sequence.
  3766.  
  3767.         ERRORS:
  3768.              File not open:      No action taken.
  3769.              Invalid cells:      Happily written to the file.
  3770.  
  3771.  
  3772.  
  3773.  
  3774.  
  3775.  
  3776.  
  3777.  
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.                                         60
  3784.  
  3785.                                                        123-Write ver 2.0
  3786.                                     Copyright (c) 1990, Thomas J. Vought
  3787.  
  3788.         NAME:           lTime
  3789.         COMPATIBILITY:  Release 2.0+ only.
  3790.         CELL POINTER:   Advanced to next column.
  3791.  
  3792.         SYNTAX:   lTime(timeStr$)
  3793.  
  3794.                   timeStr$  is a valid string representation of a
  3795.                             legitimate time.  (What?)
  3796.  
  3797.         The expected format is:   hh:mm:ss  or hh:mm
  3798.  
  3799.         Don't really know how much use there may be for this routine, but
  3800.         since I included the numeric date handling capability, I  figured
  3801.         I should also include time handling.
  3802.  
  3803.         No  extended  checking is done with the string you pass  to  this
  3804.         routine.  If it isn't eight characters (hh:mm:ss) or five charac-
  3805.         ters  (hh:mm)  it writes the string to the file  instead  of  the
  3806.         numeric  value  of  the time.  The routine is coded  to  use  the
  3807.         format set with lSetTimeForm, and if there isn't a format set, it
  3808.         uses time format 1, Lotus version 2.0+ will display it in:
  3809.                                   hh:mm:ss AM
  3810.                                       or
  3811.                                   hh:mm:ss PM
  3812.  
  3813.         The  cell contents are a fraction, indicating the fraction  of  a
  3814.         day that has passed.  The lTime sub-program, written in BASIC  is
  3815.         contained  in the LTIME.BAS file.  The assembly language  routine
  3816.         lTime1  returns the number of seconds since midnight for a  given
  3817.         time.   (ala  BASIC's  TIMER function.)   Lotus  interprets  time
  3818.         values based on the percentage of a day.  For example .25 is 6:00
  3819.         AM,  .50 is 12:00 Noon. The lTime sub divides the  seconds  since
  3820.         midnight by the number of seconds in a day, and lTime2 writes the
  3821.         result to the spreadsheet file in the currently set time format.
  3822.  
  3823.         >> NOTE <<
  3824.         Time values were not introduced in Lotus until release 2.0.   You
  3825.         may use this routine to write a worksheet that will be read by  a
  3826.         ver 1a copy of Lotus however.  The values will be correct, but it
  3827.         is  impossible to display them in "time format" with version  1a.
  3828.         The cell format indicator in 1a will display (?) instead of  (D6)
  3829.         as it does in 2.0+.
  3830.  
  3831.         EXAMPLE:
  3832.  
  3833.              CALL lTime$(TIME$)
  3834.  
  3835.         'would write the system time to the current spreadsheet cell.
  3836.  
  3837.         ERRORS:
  3838.              File not open: lTime1 will return a long int (TIMER) (CP 0)
  3839.                             lTime2 will take no action.           (CP 0)
  3840.              Invalid time$: String passed is written to the file. (CP +)
  3841.  
  3842.  
  3843.  
  3844.                                         61
  3845.  
  3846.                                                        123-Write ver 2.0
  3847.                                     Copyright (c) 1990, Thomas J. Vought
  3848.  
  3849.         NAME:           lTimeNow
  3850.         COMPATIBILITY:  Release 2.0+ only.
  3851.         CELL POINTER:   Advanced to next column.
  3852.  
  3853.         SYNTAX:   lTimeNow
  3854.  
  3855.         lTimeNow  will write the Lotus 1-2-3 version 2+ formula  @NOW  in
  3856.         the current cell.  In addition, the cell is formatted to  display
  3857.         in the currently set time format.
  3858.  
  3859.         Use lToday  to write the @NOW formula with a date display.
  3860.  
  3861.         EXAMPLE:
  3862.  
  3863.              CALL lWriteStr("The Current date is:", errCode)
  3864.              CALL lRight(2)      'adjust for long label cell
  3865.              CALL lToday
  3866.  
  3867.              CALL lWriteStr("The Current time is:", errCode)
  3868.              CALL lRight(2)      'adjust for long label cell
  3869.              CALL lTimeNow       'will display fresh time each re-calc.
  3870.  
  3871.         ERRORS:
  3872.              No file open:  No action taken.
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.                                         62
  3906.  
  3907.                                                        123-Write ver 2.0
  3908.                                     Copyright (c) 1990, Thomas J. Vought
  3909.  
  3910.         NAME:           lToday
  3911.         COMPATIBILITY:  All Releases.
  3912.         CELL POINTER:   Advanced to next column.
  3913.  
  3914.         SYNTAX:   lToday
  3915.  
  3916.         Writes  the Lotus function @TODAY/@NOW to the current cell.   The
  3917.         cell  is  formatted  for dd-mmm-yy display (D1) if  there  is  no
  3918.         default  date format set.  The system date will be  displayed  in
  3919.         the target cell when the worksheet is loaded into Lotus.
  3920.  
  3921.         When  loaded by 1-2-3 release 2.0+, the @TODAY function  is  con-
  3922.         verted to @NOW automatically.
  3923.  
  3924.         See lTimeNow for an example.
  3925.  
  3926.         ERRORS:
  3927.              No file open:  No action taken.
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964.  
  3965.  
  3966.                                         63
  3967.  
  3968.                                                        123-Write ver 2.0
  3969.                                     Copyright (c) 1990, Thomas J. Vought
  3970.  
  3971.         NAME:           lUp
  3972.         COMPATIBILITY:  All Releases.
  3973.         CELL POINTER:   Advanced to next column.
  3974.  
  3975.         SYNTAX:   lUp(count%)
  3976.  
  3977.                   count%    is the number of rows.
  3978.  
  3979.         lUp is the equivalent of hitting the up arrow key in Lotus.   The
  3980.         next  row to be written will be decreased by the number  of  rows
  3981.         the  routine is called with.  Attempts to 'cursor'  above  beyond
  3982.         row 0 will leave the cursor in row 0.
  3983.  
  3984.  
  3985.         EXAMPLE:       move% = 5
  3986.                        CALL lUp(move%)
  3987.                           'The next cell to be written will be 5 rows
  3988.                           'above the current row, in the same column.
  3989.  
  3990.         ERRORS:
  3991.              No file open:                 No action taken.
  3992.              Current column - count% < 0:  Column set to 0.
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.  
  4005.  
  4006.  
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.                                         64
  4028.  
  4029.                                                        123-Write ver 2.0
  4030.                                     Copyright (c) 1990, Thomas J. Vought
  4031.  
  4032.         NAME:           lWriteErr
  4033.         COMPATIBILITY:  All Releases.
  4034.         CELL POINTER:   Advanced to next column.
  4035.  
  4036.         SYNTAX:   lWriteErr
  4037.  
  4038.         This routine is used internally to write the function @ERR to the
  4039.         current cell when you do something out of line, like pass parame-
  4040.         ters that are outside of the allowed range.  Seems only fair that
  4041.         you  should be able to call it when an end user of  your  program
  4042.         does something out of line.
  4043.  
  4044.         I  know,  end users always respond to input prompts in  only  the
  4045.         ways we programmers expect, but it's here just in case.
  4046.  
  4047.         ERRORS:
  4048.              No file open:  No action taken.
  4049.  
  4050.  
  4051.  
  4052.  
  4053.  
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.                                         65
  4089.  
  4090.                                                        123-Write ver 2.0
  4091.                                     Copyright (c) 1990, Thomas J. Vought
  4092.  
  4093.         NAME:     lWriteInt
  4094.         NAME:     lWriteNum
  4095.         COMPATIBILITY:  All Releases.
  4096.         CELL POINTER:   Advanced to next column.
  4097.  
  4098.         SYNTAX:   lWriteInt(integerVal%, errCode%)
  4099.         SYNTAX:   lWriteNum(doubleVal#, errCode%)
  4100.  
  4101.  
  4102.         OK, so the meat and potatoes come near the end of the  documenta-
  4103.         tion.  It's alphabetical.
  4104.  
  4105.  
  4106.         Both  these  routines write a value to the current  cell.   There
  4107.         probably  isn't a need for two routines to write a numeric  value
  4108.         to  a  cell. The only difference is the resultant length  of  the
  4109.         data being written.  If your application is reading from a random
  4110.         access  file, where you know the data value is sure to be  a  two
  4111.         byte signed integer, use lWriteInt for some space saving.
  4112.  
  4113.         Any applications that need the full range of numbers should  call
  4114.         the lWriteNum routine instead, to maintain decimal values.   Note
  4115.         that  this routine requires an eight byte double precision  value
  4116.         though, not a 4 byte single precision value.
  4117.  
  4118.  
  4119.         ERRORS:
  4120.              No file open:       errCode returned as -1.
  4121.              Disk Full:          errCode returned as 1.
  4122.              DOS errors:         Dos error number returned in errCode.
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.  
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.                                         66
  4150.  
  4151.                                                        123-Write ver 2.0
  4152.                                     Copyright (c) 1990, Thomas J. Vought
  4153.  
  4154.         NAME:           lWriteStr
  4155.         COMPATIBILITY:  All Releases.
  4156.         CELL POINTER:   Advanced to next column.
  4157.  
  4158.         SYNTAX:   lWriteStr(dat$, errCode%)
  4159.  
  4160.                   dat$      string data to be written.
  4161.                   errCode%  a non-zero return indicates an error.
  4162.  
  4163.         Writes a label (string data) to the target cell.
  4164.  
  4165.         One  item of note is that the currently set label prefix  charac-
  4166.         ter,  (single quote upon startup, or what you define  as  default
  4167.         with lSetStrForm) is used if the data string sent to this routine
  4168.         does not include a label prefix character as it's first byte.  In
  4169.         other words, if you call this routine with a data string that has
  4170.         a  valid  label prefix character in the leftmost  position,  that
  4171.         prefix character will take preference.
  4172.  
  4173.         This routine will not actually write a null ("") cell. If  called
  4174.         with a null string, it  will advance the internal column  pointer
  4175.         to  the next column.  Strings of ASCII 0's or space (32)  charac-
  4176.         ters  are  written to the file.  This is a  change  from  earlier
  4177.         versions of 123-Write.
  4178.  
  4179.         EXAMPLE:
  4180.  
  4181.         CALL lFileOpen("D:\LOTUS\TESTFILE", errCode%)
  4182.  
  4183.              'default label prefix=" ' " left alignment.
  4184.              'we're at cell A1, write a title, will be left aligned.
  4185.  
  4186.         CALL lWriteStr("Test worksheet written by 123-Write", errCode%)
  4187.         CALL lLineFeed           'Then write the column headings in row 1...
  4188.         CALL lWriteStr("^Name", errCode%)               'Centered
  4189.         CALL lWriteStr("^Address", errCode%)            'Centered
  4190.         CALL lWriteStr(CHR$(34) + "Balance", errCode%)  'Right justify
  4191.         CALL lLineFeed
  4192.  
  4193.             'Next the ever popular "=======" repeating character.
  4194.  
  4195.         FOR i = 1 TO 3
  4196.            CALL lWriteStr("\=", errCode%)
  4197.         NEXT
  4198.  
  4199.         CALL lLineFeed
  4200.  
  4201.  
  4202.         ERRORS:
  4203.              No file open:       errCode returned as -1.
  4204.              Disk Full:          errCode returned as 1.
  4205.              DOS errors:         Dos error number returned in errCode.
  4206.  
  4207.  
  4208.  
  4209.  
  4210.                                         67
  4211.  
  4212.                                                        123-Write ver 2.0
  4213.                                     Copyright (c) 1990, Thomas J. Vought
  4214.  
  4215.         ERRORS.....From Lotus 1-2-3
  4216.  
  4217.         There  really shouldn't be any when you retrieve a  worksheet  in
  4218.         Lotus,  if there is advise me as soon as possible, and include  a
  4219.         printout of the code if possible.  See below on contacting me.
  4220.  
  4221.         There is a series of real nasty error messages that I encountered
  4222.         developing these routines.  Lotus beeps, prints an error  message
  4223.         "Worksheet Revision out of date.  Press HELP!" is one that  comes
  4224.         to  mind, there are a number of others too!  When you  press  F1,
  4225.         the  help  key,  a message comes up advising you  to  call  Lotus
  4226.         Customer Support right away.  Don't panic, I know I never do.  Go
  4227.         over your code and be sure that everything's being called proper-
  4228.         ly, then if need be, write me at the address on the  registration
  4229.         form.
  4230.  
  4231.         The  @ISAAF  and @ISAPP functions were added with  1-2-3  Release
  4232.         2.2.  If they are used with Release 2.0 there will be a "Formula
  4233.         Recalculation  Error" message upon loading the file.  This is  to
  4234.         be  expected, loading in a file created by 1-2-3 2.2 would  cause
  4235.         the  same  errors.  If you're not sure of the target  release  of
  4236.         1-2-3, be careful of which functions you write.
  4237.  
  4238.         123-Write ERRORS....
  4239.  
  4240.         The  only errors that will be returned by 123-Write are  the  few
  4241.         codes  returned  by some of the more  frequently  used  routines.
  4242.         Anything else is blissfully ignored.  I'm trying to make a  trade
  4243.         off  in the number of parameters that have to be passed with  the
  4244.         frequency  of  the routines.  If a routine is only to  be  called
  4245.         once  or twice in an entire file write, I felt it was not  impor-
  4246.         tant to trap DOS errors.  A routine that would be called multiple
  4247.         times, I felt, was the more likely candidate for error traps.
  4248.  
  4249.         BASIC ERRORS:
  4250.  
  4251.         These  are yours to trap or ignore or fix.  The particular  BASIC
  4252.         environment you're running under will dictate what happens.   For
  4253.         example, try lFileOpen with a floppy disk file as the target, and
  4254.         the drive door open.
  4255.  
  4256.         In QB or QBX, the environment reports the error, even though  the
  4257.         error happens in a Quick Library.  From the DOS command line, the
  4258.         run-time library will catch the error before it gets passed  back
  4259.         to  your program in non-stand alone programs.  If the program  is
  4260.         compiled  with /O, the DOS critical error handler steps  in  with
  4261.         the "Abort Retry Fail" message.
  4262.  
  4263.         So,  I  believe that if you have error trapping  enabled,  errors
  4264.         that occur in the 123-Write routines may cause that trap  routine
  4265.         to be called (runtime module should...).  Short of having a drive
  4266.         door  open,  I can't envision any way a user can  mess  up  while
  4267.         running  these routines.  (Where have I heard those  famous  last
  4268.         words before?)
  4269.  
  4270.  
  4271.                                         68
  4272.  
  4273.                                                        123-Write ver 2.0
  4274.                                     Copyright (c) 1990, Thomas J. Vought
  4275.  
  4276.         CONTACTING the author:
  4277.  
  4278.              Via Modem:
  4279.  
  4280.         Questions can be answered via a call to The Off Hour Rockers BBS,
  4281.         201-727-6917 or 201-727-6785 (N81, 9600/2400/1200) a PCBoard BBS.
  4282.         The Sysop was kind enough to give me a conference to ramble  away
  4283.         in,  so  use the J)oin command and select the  BASIC  conference.
  4284.         Leave a message to TOM VOUGHT, and it will be answered ASAP.
  4285.  
  4286.         Also, Compuserve ID: 70054,1367    (infrequent)
  4287.  
  4288.              Otherwise:
  4289.  
  4290.         Write me at:             5 John Street
  4291.                                  Morganville, NJ  07751
  4292.  
  4293.  
  4294.         FINIS:
  4295.  
  4296.         I  hope that these routines make your coding easier, and  at  the
  4297.         same  time give you the tools to improve your programs.   If  you
  4298.         enjoy  them,  let me know, if there's something you  don't  like,
  4299.         think  should  be improved, or want to see included etc,  let  me
  4300.         know.   Anyway, enjoy!
  4301.  
  4302.                                                    << Tom >>
  4303.  
  4304.  
  4305.  
  4306.  
  4307.  
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.  
  4314.  
  4315.  
  4316.  
  4317.  
  4318.  
  4319.  
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.                                         69
  4333.  
  4334.                                                        123-Write ver 2.0
  4335.                                     Copyright (c) 1990, Thomas J. Vought
  4336.  
  4337.         APPENDIX A:
  4338.  
  4339.         Possible error codes returned by DOS.
  4340.  
  4341.         This  in  not intended as a complete list of the  possible  error
  4342.         codes  that DOS might return, for that I can only refer you to  a
  4343.         good DOS reference work.
  4344.  
  4345.          ERROR CODE         MEANING
  4346.          ----------         -------
  4347.  
  4348.              1              Disk Full.  This is not generated by DOS, but
  4349.                                  by 123-Write when DOS reports fewer
  4350.                                  bytes written to disk then requested.
  4351.                                  The file is left open, so a call to
  4352.                                  lClose should be made before you termi-
  4353.                                  nate your program.
  4354.  
  4355.              2              File Not Found.  lFileAppend, the path is
  4356.                                  there, but the file isn't.
  4357.  
  4358.              3              Path Not Found.  lFileOpen or lFileAppend,
  4359.                                  indicates an invalid drive or path spec.
  4360.  
  4361.         Note that DOS's critical error handler may intercept some errors.
  4362.         A "Drive not ready" error, for example, results  in the  familiar
  4363.         A)bort  R)etry  F)ail message.  If the user selects  Abort,  your
  4364.         program may terminate, choosing Fail will result in an error code
  4365.         being  passed  back to your program by 123-Write (3 in  this  in-
  4366.         stance).
  4367.  
  4368.  
  4369.  
  4370.  
  4371.  
  4372.  
  4373.  
  4374.  
  4375.  
  4376.  
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.                                         70
  4394. Routine reference.
  4395.                                                           1-2-3 
  4396.                                                          Release    Page
  4397.  
  4398. LBoolean (col1%, row1%, col2%, row2%, operation%),         ALL       18
  4399. LCellFunction(dSeg%, dOfs%)                                MIXED     19
  4400. LCellMath(col1%, row1%, col2%, row2%, oper%)               ALL       23
  4401. LClose                                                     ALL       24
  4402. LCol (column$)                                             ALL       25
  4403. LColFunction (startRow%, endRow%, oper%)                   MIXED     26
  4404. LConstMath(col%, row%, constVal#, oper%)                   ALL       27
  4405. LDate(dat$)                                                ALL       28
  4406. LDown(count%)                                              ALL       29
  4407. LFileAppend(fileName$, ecode%)                             ALL       30
  4408. LFileOpen(fileName$, errCode%)                             ALL       32
  4409. LGetLoc(whatCol%, whatRow%)                                ALL       33
  4410. LGlobal(item%, switch%)                                    ALL       34
  4411. LHideCol(col%, writeFlag%)                                 2.0+      35
  4412. LLeft(count%)                                              ALL       36
  4413. LLineFeed                                                  ALL       37
  4414. LLink(fileSpecRange$)                                      2.2       38
  4415. LMultiCellMath(dSeg%, dOfs%)                               ALL       40
  4416. LPrintBorders_                                             ALL       43
  4417.    (rulc%, rulr%, rlrc%, rlrr%, culc%, culr%, clrc%, clrr%)
  4418. LPrintMargins(lm%, rm%, tm%, bm%, pageLen%)                ALL       44
  4419. LPrintRange (ulc%, ulr%, lrc%, lrr%)                       ALL       45
  4420. LPrintSetup (setup$)                                       ALL       46
  4421. LPrintTitle (title$, header%)                              ALL       47
  4422. LRange(rangeName$, ulc%, ulr%, lrc%, lrr%)                 ALL       48
  4423. LRight(count%)                                             ALL       49
  4424. LRowFunction(startCol%, endCol%, oper%)                    MIXED     50
  4425. LSetCellForm(formatCode%, decimals%)                       MIXED     51
  4426. LSetCol(col%, colWidth%)                                   ALL       53
  4427. LSetCols(colWidths%())                                     ALL       54
  4428. LSetDateForm (format%, protect%)                           MIXED     55
  4429. LSetLoc(newCol%, newRow%)                                  ALL       56
  4430. LSetStrForm(formatCode%)                                   MIXED     57
  4431. LSetTimeForm (format%, protect%)                           2.0+      58
  4432. LSortKey (primry%, ulc%, ulr%, lrc%, lrr%, ascnd%)         ALL       59
  4433. LSortRange(ulc%, ulr%, lrc%, lrr%)                         ALL       60
  4434. LTime(timeStr$)                                            2.0+      61
  4435. LTimeNow                                                   2.0+      62
  4436. LToday                                                     ALL       63
  4437. LUp(count%)                                                ALL       64
  4438. LWriteErr                                                  ALL       65
  4439. LWriteInt(integerVal%, errCode%)                           ALL       66
  4440. LWriteNum(doubleVal#, errCode%)                            ALL       66
  4441. LWriteStr(dat$, errCode%)                                  ALL       67
  4442.  
  4443.  
  4444.                            
  4445.  
  4446.  
  4447.  
  4448.  
  4449.  
  4450.  
  4451.  
  4452.  
  4453.  
  4454.                                         71
  4455. 
  4456.